mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-28 19:35:36 +02:00
API cleanup & JavaDoc
This commit is contained in:
parent
ba7591a95b
commit
da8e44baef
13 changed files with 222 additions and 210 deletions
|
@ -141,17 +141,22 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAbstractBuiltinSpecsDetector_GettersSetters() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_GettersSetters() throws Exception {
|
||||||
// define mock detector
|
{
|
||||||
|
// provider configured with null parameters
|
||||||
MockBuiltinSpecsDetectorExecutedFlag detector = new MockBuiltinSpecsDetectorExecutedFlag();
|
MockBuiltinSpecsDetectorExecutedFlag detector = new MockBuiltinSpecsDetectorExecutedFlag();
|
||||||
|
|
||||||
detector.configureProvider(PROVIDER_ID, PROVIDER_NAME, null, null, null);
|
detector.configureProvider(PROVIDER_ID, PROVIDER_NAME, null, null, null);
|
||||||
|
|
||||||
assertEquals(PROVIDER_ID, detector.getId());
|
assertEquals(PROVIDER_ID, detector.getId());
|
||||||
assertEquals(PROVIDER_NAME, detector.getName());
|
assertEquals(PROVIDER_NAME, detector.getName());
|
||||||
assertEquals(null, detector.getLanguageScope());
|
assertEquals(null, detector.getLanguageScope());
|
||||||
assertEquals(null, detector.getSettingEntries(null, null, null));
|
assertEquals(null, detector.getSettingEntries(null, null, null));
|
||||||
assertEquals(null, detector.getCustomParameter());
|
assertEquals(null, detector.getCustomParameter());
|
||||||
assertEquals(false, detector.isExecuted());
|
assertEquals(false, detector.isExecuted());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// provider configured with non-null parameters
|
||||||
|
MockBuiltinSpecsDetectorExecutedFlag detector = new MockBuiltinSpecsDetectorExecutedFlag();
|
||||||
List<String> languages = new ArrayList<String>();
|
List<String> languages = new ArrayList<String>();
|
||||||
languages.add(LANGUAGE_ID);
|
languages.add(LANGUAGE_ID);
|
||||||
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
@ -169,6 +174,7 @@ public class BuiltinSpecsDetectorTest extends BaseTestCase {
|
||||||
detector.execute();
|
detector.execute();
|
||||||
assertEquals(true, detector.isExecuted());
|
assertEquals(true, detector.isExecuted());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void testAbstractBuiltinSpecsDetector_CloneAndEquals() throws Exception {
|
public void testAbstractBuiltinSpecsDetector_CloneAndEquals() throws Exception {
|
||||||
// define mock detector
|
// define mock detector
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2009 Andrew Gvozdev (Quoin Inc.) and others.
|
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
|
package org.eclipse.cdt.managedbuilder.internal.scannerconfig;
|
||||||
|
|
|
@ -226,6 +226,25 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LanguageSettingsBaseProvider is not allowed to be configured twice.
|
||||||
|
*/
|
||||||
|
public void testBaseProviderCantReconfigure() throws Exception {
|
||||||
|
// create LanguageSettingsBaseProvider
|
||||||
|
LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider();
|
||||||
|
List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
entries.add(new CIncludePathEntry("/usr/include/", 0));
|
||||||
|
// configure it
|
||||||
|
provider.configureProvider("id", "name", null, entries, null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// attempt to configure it twice should fail
|
||||||
|
provider.configureProvider("id", "name", null, entries, null);
|
||||||
|
fail("LanguageSettingsBaseProvider is not allowed to be configured twice");
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO
|
* TODO
|
||||||
*/
|
*/
|
||||||
|
@ -299,27 +318,7 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase {
|
||||||
|
|
||||||
assertFalse(LanguageSettingsExtensionManager.equalsExtensionProvider(providerShallow));
|
assertFalse(LanguageSettingsExtensionManager.equalsExtensionProvider(providerShallow));
|
||||||
assertTrue(LanguageSettingsExtensionManager.equalsExtensionProviderShallow((ILanguageSettingsEditableProvider) providerShallow));
|
assertTrue(LanguageSettingsExtensionManager.equalsExtensionProviderShallow((ILanguageSettingsEditableProvider) providerShallow));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * LanguageSettingsBaseProvider is not allowed to be configured twice.
|
|
||||||
// */
|
|
||||||
// public void testBaseProviderConfigure() throws Exception {
|
|
||||||
// // create LanguageSettingsBaseProvider
|
|
||||||
// LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider();
|
|
||||||
// List<ICLanguageSettingEntry> entries = new ArrayList<ICLanguageSettingEntry>();
|
|
||||||
// entries.add(new CIncludePathEntry("/usr/include/", 0));
|
|
||||||
// // configure it
|
|
||||||
// provider.configureProvider("id", "name", null, entries, null);
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// // attempt to configure it twice should fail
|
|
||||||
// provider.configureProvider("id", "name", null, entries, null);
|
|
||||||
// fail("LanguageSettingsBaseProvider is not allowed to be configured twice");
|
|
||||||
// } catch (UnsupportedOperationException e) {
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2010 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2011 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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009 Andrew Gvozdev and others.
|
* Copyright (c) 2009, 2011 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
|
||||||
|
@ -1238,17 +1238,17 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
|
||||||
sampleLanguages.add(LANG_ID);
|
sampleLanguages.add(LANG_ID);
|
||||||
|
|
||||||
// create a model provider
|
// create a model provider
|
||||||
class LanguageSettingsSerializableMock extends LanguageSettingsSerializableProvider implements Cloneable {
|
class MockSerializableProvider extends LanguageSettingsSerializableProvider implements Cloneable {
|
||||||
public LanguageSettingsSerializableMock(String id, String name) {
|
public MockSerializableProvider(String id, String name) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public LanguageSettingsSerializableMock clone() throws CloneNotSupportedException {
|
public MockSerializableProvider clone() throws CloneNotSupportedException {
|
||||||
return (LanguageSettingsSerializableMock) super.clone();
|
return (MockSerializableProvider) super.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
LanguageSettingsSerializableMock provider1 = new LanguageSettingsSerializableMock(PROVIDER_1, PROVIDER_NAME_1);
|
MockSerializableProvider provider1 = new MockSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
provider1.setLanguageScope(sampleLanguages);
|
provider1.setLanguageScope(sampleLanguages);
|
||||||
provider1.setCustomParameter(CUSTOM_PARAMETER);
|
provider1.setCustomParameter(CUSTOM_PARAMETER);
|
||||||
assertEquals(false, provider1.isStoringEntriesInProjectArea());
|
assertEquals(false, provider1.isStoringEntriesInProjectArea());
|
||||||
|
@ -1257,7 +1257,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
|
||||||
provider1.setSettingEntries(null, null, LANG_ID, sampleEntries_2);
|
provider1.setSettingEntries(null, null, LANG_ID, sampleEntries_2);
|
||||||
|
|
||||||
// clone provider
|
// clone provider
|
||||||
LanguageSettingsSerializableMock providerClone = provider1.clone();
|
MockSerializableProvider providerClone = provider1.clone();
|
||||||
assertNotSame(provider1, providerClone);
|
assertNotSame(provider1, providerClone);
|
||||||
assertTrue(provider1.equals(providerClone));
|
assertTrue(provider1.equals(providerClone));
|
||||||
assertTrue(provider1.getClass()==providerClone.getClass());
|
assertTrue(provider1.getClass()==providerClone.getClass());
|
||||||
|
@ -1286,17 +1286,17 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
|
||||||
sampleLanguages.add(LANG_ID);
|
sampleLanguages.add(LANG_ID);
|
||||||
|
|
||||||
// create a model provider
|
// create a model provider
|
||||||
class LanguageSettingsSerializableMock extends LanguageSettingsSerializableProvider implements Cloneable {
|
class MockSerializableProvider extends LanguageSettingsSerializableProvider implements Cloneable {
|
||||||
public LanguageSettingsSerializableMock(String id, String name) {
|
public MockSerializableProvider(String id, String name) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public LanguageSettingsSerializableMock cloneShallow() throws CloneNotSupportedException {
|
public MockSerializableProvider cloneShallow() throws CloneNotSupportedException {
|
||||||
return (LanguageSettingsSerializableMock) super.cloneShallow();
|
return (MockSerializableProvider) super.cloneShallow();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
LanguageSettingsSerializableMock provider1 = new LanguageSettingsSerializableMock(PROVIDER_1, PROVIDER_NAME_1);
|
MockSerializableProvider provider1 = new MockSerializableProvider(PROVIDER_1, PROVIDER_NAME_1);
|
||||||
provider1.setLanguageScope(sampleLanguages);
|
provider1.setLanguageScope(sampleLanguages);
|
||||||
provider1.setCustomParameter(CUSTOM_PARAMETER);
|
provider1.setCustomParameter(CUSTOM_PARAMETER);
|
||||||
assertEquals(false, provider1.isStoringEntriesInProjectArea());
|
assertEquals(false, provider1.isStoringEntriesInProjectArea());
|
||||||
|
@ -1307,7 +1307,7 @@ public class LanguageSettingsSerializableTests extends BaseTestCase {
|
||||||
provider1.setSettingEntries(null, null, null, entries);
|
provider1.setSettingEntries(null, null, null, entries);
|
||||||
|
|
||||||
// clone provider
|
// clone provider
|
||||||
LanguageSettingsSerializableMock providerClone = provider1.cloneShallow();
|
MockSerializableProvider providerClone = provider1.cloneShallow();
|
||||||
assertNotSame(provider1, providerClone);
|
assertNotSame(provider1, providerClone);
|
||||||
assertFalse(provider1.equals(providerClone));
|
assertFalse(provider1.equals(providerClone));
|
||||||
assertTrue(provider1.getClass()==providerClone.getClass());
|
assertTrue(provider1.getClass()==providerClone.getClass());
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2009 Andrew Gvozdev (Quoin Inc.) and others.
|
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.language.settings.providers;
|
package org.eclipse.cdt.core.language.settings.providers;
|
||||||
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.core.language.settings.providers;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
||||||
import org.eclipse.cdt.core.language.settings.providers.ILanguageSettingsProvider;
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -22,6 +21,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
public class MockLanguageSettingsProvider extends AbstractExecutableExtensionBase
|
||||||
implements ILanguageSettingsProvider {
|
implements ILanguageSettingsProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
|
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2009 Andrew Gvozdev (Quoin Inc.) and others.
|
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core.language.settings.providers;
|
package org.eclipse.cdt.core.language.settings.providers;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.core.resources.IResource;
|
||||||
* This interface is used to deliver additions to compiler options such as
|
* This interface is used to deliver additions to compiler options such as
|
||||||
* include paths (-I) or preprocessor defines (-D) and others (see
|
* include paths (-I) or preprocessor defines (-D) and others (see
|
||||||
* {@link ICSettingEntry#INCLUDE_PATH} and other kinds).
|
* {@link ICSettingEntry#INCLUDE_PATH} and other kinds).
|
||||||
* <br>
|
* <br><br>
|
||||||
* To define a provider like that use extension point
|
* To define a provider like that use extension point
|
||||||
* {@code org.eclipse.cdt.core.LanguageSettingsProvider} and implement this
|
* {@code org.eclipse.cdt.core.LanguageSettingsProvider} and implement this
|
||||||
* interface. CDT provides a few general use implementations such as
|
* interface. CDT provides a few general use implementations such as
|
||||||
|
|
|
@ -18,11 +18,13 @@ import java.util.List;
|
||||||
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
import org.eclipse.cdt.core.AbstractExecutableExtensionBase;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||||
|
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsStorage;
|
||||||
|
import org.eclipse.cdt.internal.core.settings.model.SettingsModelMessages;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code LanguageSettingsBaseProvider} is a basic implementation of {@link ILanguageSettingsProvider}
|
* {@code LanguageSettingsBaseProvider} is a basic implementation of {@link ILanguageSettingsProvider}
|
||||||
* defined in {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point.
|
* for the extensions defined by {@code org.eclipse.cdt.core.LanguageSettingsProvider} extension point.
|
||||||
*
|
*
|
||||||
* This implementation supports "static" list of entries for languages specified in
|
* This implementation supports "static" list of entries for languages specified in
|
||||||
* the extension point.
|
* the extension point.
|
||||||
|
@ -43,10 +45,11 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
* Default constructor.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
public LanguageSettingsBaseProvider() {
|
public LanguageSettingsBaseProvider() {
|
||||||
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor. Creates an "empty" provider.
|
* Constructor. Creates an "empty" non-configured provider.
|
||||||
*
|
*
|
||||||
* @param id - id of the provider.
|
* @param id - id of the provider.
|
||||||
* @param name - name of the provider to be presented to a user.
|
* @param name - name of the provider to be presented to a user.
|
||||||
|
@ -66,10 +69,11 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
* @param entries - the list of language settings entries this provider provides.
|
* @param entries - the list of language settings entries this provider provides.
|
||||||
* If {@code null} is passed, the provider creates an empty list.
|
* If {@code null} is passed, the provider creates an empty list.
|
||||||
*/
|
*/
|
||||||
public LanguageSettingsBaseProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries) {
|
public LanguageSettingsBaseProvider(String id, String name, List<String> languages,
|
||||||
|
List<ICLanguageSettingEntry> entries) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
||||||
this.entries = cloneList(entries);
|
this.entries = getPooledList(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,10 +89,11 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
* @param customParameter - a custom parameter as the means to customize
|
* @param customParameter - a custom parameter as the means to customize
|
||||||
* providers extending this class.
|
* providers extending this class.
|
||||||
*/
|
*/
|
||||||
public LanguageSettingsBaseProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries, String customParameter) {
|
public LanguageSettingsBaseProvider(String id, String name, List<String> languages,
|
||||||
|
List<ICLanguageSettingEntry> entries, String customParameter) {
|
||||||
super(id, name);
|
super(id, name);
|
||||||
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
||||||
this.entries = cloneList(entries);
|
this.entries = getPooledList(entries);
|
||||||
this.customParameter = customParameter;
|
this.customParameter = customParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +102,8 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
* the extension point is done in 2 steps. First, the class is created as
|
* the extension point is done in 2 steps. First, the class is created as
|
||||||
* an executable extension using the default provider. Then this method is
|
* an executable extension using the default provider. Then this method is
|
||||||
* used to configure the provider.
|
* used to configure the provider.
|
||||||
*
|
*<br><br>
|
||||||
* FIXME It is not allowed to reconfigure the provider.
|
* It is not allowed to reconfigure the provider.
|
||||||
*
|
*
|
||||||
* @param id - id of the provider.
|
* @param id - id of the provider.
|
||||||
* @param name - name of the provider to be presented to a user.
|
* @param name - name of the provider to be presented to a user.
|
||||||
|
@ -110,45 +115,53 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
* @param customParameter - a custom parameter as the means to customize
|
* @param customParameter - a custom parameter as the means to customize
|
||||||
* providers extending this class from extension definition in {@code plugin.xml}.
|
* providers extending this class from extension definition in {@code plugin.xml}.
|
||||||
*
|
*
|
||||||
* FIXME @throws UnsupportedOperationException if an attempt to reconfigure provider is made.
|
* @throws UnsupportedOperationException if an attempt to reconfigure provider is made.
|
||||||
*/
|
*/
|
||||||
public void configureProvider(String id, String name, List<String> languages, List<ICLanguageSettingEntry> entries, String customParameter) {
|
public void configureProvider(String id, String name, List<String> languages,
|
||||||
// if (this.entries!=null)
|
List<ICLanguageSettingEntry> entries, String customParameter) {
|
||||||
// throw new UnsupportedOperationException(SettingsModelMessages.getString("LanguageSettingsBaseProvider.CanBeConfiguredOnlyOnce")); //$NON-NLS-1$
|
if (this.entries!=null)
|
||||||
|
throw new UnsupportedOperationException(SettingsModelMessages.getString("LanguageSettingsBaseProvider.CanBeConfiguredOnlyOnce")); //$NON-NLS-1$
|
||||||
|
|
||||||
setId(id);
|
setId(id);
|
||||||
setName(name);
|
setName(name);
|
||||||
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
this.languageScope = languages!=null ? new ArrayList<String>(languages) : null;
|
||||||
this.entries = cloneList(entries);
|
this.entries = getPooledList(entries);
|
||||||
this.customParameter = customParameter;
|
this.customParameter = customParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<ICLanguageSettingEntry> getPooledList(List<ICLanguageSettingEntry> entries) {
|
||||||
|
if (entries != null) {
|
||||||
|
return LanguageSettingsStorage.getPooledList(entries);
|
||||||
|
}
|
||||||
|
return LanguageSettingsStorage.getPooledEmptyList();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
* @param cfgDescription - configuration description.
|
*
|
||||||
* @param rc - resource such as file or folder.
|
|
||||||
* @param languageId - language id. If {@code null}, then entries defined for
|
* @param languageId - language id. If {@code null}, then entries defined for
|
||||||
* the language scope are returned. See {@link #getLanguageScope()}
|
* the language scope are returned. See {@link #getLanguageScope()}
|
||||||
|
*
|
||||||
|
* @return unmodifiable list of setting entries or {@code null} if no settings defined.
|
||||||
|
* the list is internally pooled and guaranteed to be the same object for equal
|
||||||
|
* lists.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription, IResource rc, String languageId) {
|
public List<ICLanguageSettingEntry> getSettingEntries(ICConfigurationDescription cfgDescription,
|
||||||
|
IResource rc, String languageId) {
|
||||||
if (languageScope == null) {
|
if (languageScope == null) {
|
||||||
if (entries==null)
|
return entries;
|
||||||
return null;
|
|
||||||
return Collections.unmodifiableList(entries);
|
|
||||||
}
|
}
|
||||||
for (String lang : languageScope) {
|
for (String lang : languageScope) {
|
||||||
if (lang.equals(languageId)) {
|
if (lang.equals(languageId)) {
|
||||||
if (entries==null)
|
return entries;
|
||||||
return null;
|
|
||||||
return Collections.unmodifiableList(entries);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the list of languages this provider provides for.
|
* @return the unmodifiable list of languages this provider provides for.
|
||||||
* If {@code null}, the provider provides for any language.
|
* If {@code null}, the provider provides for any language.
|
||||||
*/
|
*/
|
||||||
public List<String> getLanguageScope() {
|
public List<String> getLanguageScope() {
|
||||||
|
@ -163,13 +176,4 @@ public class LanguageSettingsBaseProvider extends AbstractExecutableExtensionBas
|
||||||
public String getCustomParameter() {
|
public String getCustomParameter() {
|
||||||
return customParameter;
|
return customParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param entries
|
|
||||||
* @return copy of the list of the entries.
|
|
||||||
*/
|
|
||||||
private List<ICLanguageSettingEntry> cloneList(List<ICLanguageSettingEntry> entries) {
|
|
||||||
return entries!=null ? new ArrayList<ICLanguageSettingEntry>(entries) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,7 @@ public class ScannerDiscoveryLegacySupport {
|
||||||
legacyProfiles = new HashMap<String, String>();
|
legacyProfiles = new HashMap<String, String>();
|
||||||
|
|
||||||
// InputTypes
|
// InputTypes
|
||||||
|
// TODO -doublecheck
|
||||||
// legacyProfiles.put(inputTypeId, scannerConfigDiscoveryProfileId);
|
// legacyProfiles.put(inputTypeId, scannerConfigDiscoveryProfileId);
|
||||||
legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
|
legacyProfiles.put("cdt.managedbuild.tool.gnu.c.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
|
||||||
legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
|
legacyProfiles.put("cdt.managedbuild.tool.gnu.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP|org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile");
|
||||||
|
@ -120,6 +121,7 @@ public class ScannerDiscoveryLegacySupport {
|
||||||
legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
|
legacyProfiles.put("cdt.managedbuild.tool.xlc.cpp.compiler.input", "org.eclipse.cdt.managedbuilder.xlc.core.XLCManagedMakePerProjectProfileCPP");
|
||||||
|
|
||||||
// Toolchains
|
// Toolchains
|
||||||
|
// TODO -doublecheck
|
||||||
// legacyProfiles.put(toolchainId, scannerConfigDiscoveryProfileId);
|
// legacyProfiles.put(toolchainId, scannerConfigDiscoveryProfileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ public class LanguageSettingsExtensionManager {
|
||||||
loadProviderExtensions();
|
loadProviderExtensions();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
CCorePlugin.log("Error loading language settings providers extensions", e); //$NON-NLS-1$
|
CCorePlugin.log("Error loading language settings providers extensions", e); //$NON-NLS-1$
|
||||||
} finally {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +78,7 @@ public class LanguageSettingsExtensionManager {
|
||||||
* Load language settings providers contributed via the extension point.
|
* Load language settings providers contributed via the extension point.
|
||||||
*/
|
*/
|
||||||
synchronized private static void loadProviderExtensions() {
|
synchronized private static void loadProviderExtensions() {
|
||||||
// sort by name - for the providers taken from platform extensions
|
// sort by name - the providers defined via extensions are kept in separate list sorted
|
||||||
Set<ILanguageSettingsProvider> sortedProviders = new TreeSet<ILanguageSettingsProvider>(
|
Set<ILanguageSettingsProvider> sortedProviders = new TreeSet<ILanguageSettingsProvider>(
|
||||||
new Comparator<ILanguageSettingsProvider>() {
|
new Comparator<ILanguageSettingsProvider>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -169,7 +168,7 @@ public class LanguageSettingsExtensionManager {
|
||||||
|
|
||||||
for (IConfigurationElement ceLang : ce.getChildren(ELEM_LANGUAGE_SCOPE)) {
|
for (IConfigurationElement ceLang : ce.getChildren(ELEM_LANGUAGE_SCOPE)) {
|
||||||
String langId = determineAttributeValue(ceLang, ATTR_ID);
|
String langId = determineAttributeValue(ceLang, ATTR_ID);
|
||||||
if (langId.trim().length()>0) {
|
if (langId.length() > 0) {
|
||||||
if (languages == null) {
|
if (languages == null) {
|
||||||
languages = new ArrayList<String>();
|
languages = new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
@ -192,8 +191,9 @@ public class LanguageSettingsExtensionManager {
|
||||||
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(
|
ICLanguageSettingEntry entry = (ICLanguageSettingEntry) CDataUtil.createEntry(
|
||||||
entryKind, entryName, entryValue, null, flags);
|
entryKind, entryName, entryValue, null, flags);
|
||||||
|
|
||||||
if (entries == null)
|
if (entries == null) {
|
||||||
entries = new ArrayList<ICLanguageSettingEntry>();
|
entries = new ArrayList<ICLanguageSettingEntry>();
|
||||||
|
}
|
||||||
entries.add(entry);
|
entries.add(entry);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -213,7 +213,7 @@ public class LanguageSettingsExtensionManager {
|
||||||
* Creates empty non-configured provider from extension point definition. The method will
|
* Creates empty non-configured provider from extension point definition. The method will
|
||||||
* inspect extension registry for extension point "org.eclipse.cdt.core.LanguageSettingsProvider"
|
* inspect extension registry for extension point "org.eclipse.cdt.core.LanguageSettingsProvider"
|
||||||
* to determine bundle and instantiate the class.
|
* to determine bundle and instantiate the class.
|
||||||
* ID and name of provider are assigned from first extension point encountered.
|
* ID and name of provider are assigned from the first encountered extension point specifying the class.
|
||||||
*
|
*
|
||||||
* @param className - full qualified class name of provider.
|
* @param className - full qualified class name of provider.
|
||||||
* @param registry - extension registry
|
* @param registry - extension registry
|
||||||
|
|
|
@ -65,7 +65,8 @@
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
A fully qualified name of the Java class that implements <samp>org.eclipse.cdt.core.settings.model.ILanguageSettingsProvider</samp> interface. If empty, <samp>org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider</samp> is used by default which provides basic functionality defined by this extension point.
|
A fully qualified name of the Java class that implements <samp>org.eclipse.cdt.core.settings.model.ILanguageSettingsProvider</samp> interface. If empty, <samp>org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider</samp> is used by default which provides basic functionality defined by this extension point.
|
||||||
If there is a need to configure a provider, attribute parameter could be used in a class extending <samp>LanguageSettingsBaseProvider</samp>.
|
If there is a need to configure a provider in more deliberate way, attribute <samp>parameter</samp> could be used in a class extending <samp>LanguageSettingsBaseProvider</samp>.
|
||||||
|
Default constructor (constructor without arguments) of this class must be public and the package be exported in order to be able to instantiate via extension point.
|
||||||
</documentation>
|
</documentation>
|
||||||
<appInfo>
|
<appInfo>
|
||||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider:org.eclipse.cdt.core.settings.model.ILanguageSettingsProvider"/>
|
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.language.settings.providers.LanguageSettingsBaseProvider:org.eclipse.cdt.core.settings.model.ILanguageSettingsProvider"/>
|
||||||
|
@ -89,7 +90,7 @@ If there is a need to configure a provider, attribute parameter could be used in
|
||||||
<attribute name="parameter" type="string">
|
<attribute name="parameter" type="string">
|
||||||
<annotation>
|
<annotation>
|
||||||
<documentation>
|
<documentation>
|
||||||
A custom parameter to initialize provider. Used to deliver command for GCCBuiltinSpecsDetector as an example.
|
A custom parameter to initialize provider. For example, used to deliver command for GCCBuiltinSpecsDetector.
|
||||||
</documentation>
|
</documentation>
|
||||||
</annotation>
|
</annotation>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
@ -256,7 +257,7 @@ For those cases where contributed settings entries (representing the compiler op
|
||||||
<meta.section type="copyright"/>
|
<meta.section type="copyright"/>
|
||||||
</appInfo>
|
</appInfo>
|
||||||
<documentation>
|
<documentation>
|
||||||
Copyright (c) 2009, 2010 Andrew Gvozdev (Quoin Inc.) and others.
|
Copyright (c) 2009, 2011 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
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2010 Andrew Gvozdev (Quoin Inc.) and others.
|
* Copyright (c) 2009, 2011 Andrew Gvozdev and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev (Quoin Inc.) - initial API and implementation
|
* Andrew Gvozdev - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.core;
|
package org.eclipse.cdt.core;
|
||||||
|
|
Loading…
Add table
Reference in a new issue