mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-02 14:45:25 +02:00
LanguageSettingsSerializableProvider.serializeLanguageSettings(ICConfigurationDescription)
This commit is contained in:
parent
60239b57ca
commit
115f78f7aa
3 changed files with 39 additions and 34 deletions
|
@ -27,13 +27,11 @@ import org.eclipse.cdt.core.errorparsers.RegexErrorPattern;
|
|||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
|
||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||
import org.eclipse.core.resources.IFolder;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
|
@ -160,18 +158,7 @@ public abstract class AbstractBuildCommandParser extends AbstractLanguageSetting
|
|||
Job job = new Job("Serialize CDT language settings entries") {
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
IStatus status = Status.OK_STATUS;
|
||||
try {
|
||||
if (cfgDescription != null) {
|
||||
LanguageSettingsManager.serializeLanguageSettings(cfgDescription.getProjectDescription());
|
||||
} else {
|
||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
status = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error serializing language settings", e);
|
||||
MakeCorePlugin.log(status);
|
||||
}
|
||||
return status;
|
||||
return serializeLanguageSettings(cfgDescription);
|
||||
}
|
||||
@Override
|
||||
public boolean belongsTo(Object family) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.eclipse.cdt.core.IMarkerGenerator;
|
|||
import org.eclipse.cdt.core.ProblemMarkerInfo;
|
||||
import org.eclipse.cdt.core.index.IIndexManager;
|
||||
import org.eclipse.cdt.core.language.settings.providers.ICListenerAgent;
|
||||
import org.eclipse.cdt.core.language.settings.providers.LanguageSettingsManager;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
|
@ -400,17 +399,8 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
|||
|
||||
monitor.subTask("Serializing results");
|
||||
if (isChanged) { // avoids resource and settings change notifications
|
||||
try {
|
||||
if (currentCfgDescription != null) {
|
||||
LanguageSettingsManager.serializeLanguageSettings(currentCfgDescription.getProjectDescription());
|
||||
} else {
|
||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error serializing language settings", e);
|
||||
MakeCorePlugin.log(s);
|
||||
status.merge(s);
|
||||
}
|
||||
IStatus s = serializeLanguageSettings(currentCfgDescription);
|
||||
status.merge(s);
|
||||
|
||||
// AG: FIXME - rather send event that ls settings changed
|
||||
if (currentCfgDescription != null) {
|
||||
|
@ -419,9 +409,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti
|
|||
try {
|
||||
CCorePlugin.getIndexManager().update(tuSelection, IIndexManager.UPDATE_ALL | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT);
|
||||
} catch (CoreException e) {
|
||||
IStatus s = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error updating CDT index", e);
|
||||
MakeCorePlugin.log(s);
|
||||
status.merge(s);
|
||||
IStatus s2 = new Status(IStatus.ERROR, MakeCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error updating CDT index", e);
|
||||
MakeCorePlugin.log(s2);
|
||||
status.merge(s2);
|
||||
}
|
||||
} else {
|
||||
// TODO
|
||||
|
|
|
@ -19,11 +19,13 @@ import java.util.Map.Entry;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.internal.core.XmlUtil;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer;
|
||||
import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsSerializableStorage;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
@ -119,10 +121,9 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
|
|||
|
||||
/**
|
||||
* Sets language settings entries for the provider.
|
||||
* Note that the entries are not persisted at that point. Use this method to
|
||||
* set the entries for all resources and then to persist use
|
||||
* {@link LanguageSettingsManager#serializeLanguageSettings(ICProjectDescription)} or
|
||||
* {@link LanguageSettingsManager#serializeLanguageSettingsWorkspace()}.
|
||||
* Note that the entries are not persisted at that point. Use this method to set
|
||||
* the entries for all resources one by one and after all done persist in one shot
|
||||
* using {@link #serializeLanguageSettings(ICConfigurationDescription)}.
|
||||
* See for example {@code AbstractBuildCommandParser} and {@code AbstractBuiltinSpecsDetector}
|
||||
* in build plugins.
|
||||
*
|
||||
|
@ -228,6 +229,33 @@ public class LanguageSettingsSerializableProvider extends LanguageSettingsBasePr
|
|||
fStorage.serializeEntries(elementProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to persist language settings entries for the project or
|
||||
* workspace as often-used operation.
|
||||
* Note that configuration description is passed as an argument but the
|
||||
* current implementation saves all configurations.
|
||||
*
|
||||
* @param cfgDescription - configuration description.
|
||||
* If not {@code null}, all providers of the project are serialized.
|
||||
* If {@code null}, global workspace providers are serialized.
|
||||
*
|
||||
* @return - status of operation.
|
||||
*/
|
||||
public IStatus serializeLanguageSettings(ICConfigurationDescription cfgDescription) {
|
||||
IStatus status = Status.OK_STATUS;
|
||||
try {
|
||||
if (cfgDescription != null) {
|
||||
LanguageSettingsManager.serializeLanguageSettings(cfgDescription.getProjectDescription());
|
||||
} else {
|
||||
LanguageSettingsManager.serializeLanguageSettingsWorkspace();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
status = new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, IStatus.ERROR, "Error serializing language settings", e); //$NON-NLS-1$
|
||||
CCorePlugin.log(status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load provider from XML provider element.
|
||||
* This is convenience method not intended to be overridden on purpose.
|
||||
|
|
Loading…
Add table
Reference in a new issue