use of org.jetbrains.jps.model.serialization.JpsModelSerializerExtension in project intellij-community by JetBrains.
the class JpsModuleRootModelSerializer method loadRootModel.
public static void loadRootModel(JpsModule module, @Nullable Element rootModelComponent, @Nullable JpsSdkType<?> projectSdkType) {
if (rootModelComponent == null)
return;
for (Element contentElement : getChildren(rootModelComponent, CONTENT_TAG)) {
final String url = contentElement.getAttributeValue(URL_ATTRIBUTE);
module.getContentRootsList().addUrl(url);
for (Element sourceElement : getChildren(contentElement, SOURCE_FOLDER_TAG)) {
module.addSourceRoot(loadSourceRoot(sourceElement));
}
for (Element excludeElement : getChildren(contentElement, EXCLUDE_FOLDER_TAG)) {
module.getExcludeRootsList().addUrl(excludeElement.getAttributeValue(URL_ATTRIBUTE));
}
}
final JpsDependenciesList dependenciesList = module.getDependenciesList();
dependenciesList.clear();
final JpsElementFactory elementFactory = JpsElementFactory.getInstance();
UniqueNameGenerator nameGenerator = new UniqueNameGenerator();
boolean moduleSourceAdded = false;
for (Element orderEntry : getChildren(rootModelComponent, ORDER_ENTRY_TAG)) {
String type = orderEntry.getAttributeValue(TYPE_ATTRIBUTE);
if (SOURCE_FOLDER_TYPE.equals(type)) {
dependenciesList.addModuleSourceDependency();
moduleSourceAdded = true;
} else if (JDK_TYPE.equals(type)) {
String sdkName = orderEntry.getAttributeValue(JDK_NAME_ATTRIBUTE);
String sdkTypeId = orderEntry.getAttributeValue(JDK_TYPE_ATTRIBUTE);
final JpsSdkType<?> sdkType = JpsSdkTableSerializer.getSdkType(sdkTypeId);
dependenciesList.addSdkDependency(sdkType);
JpsSdkTableSerializer.setSdkReference(module.getSdkReferencesTable(), sdkName, sdkType);
if (sdkType instanceof JpsJavaSdkTypeWrapper) {
dependenciesList.addSdkDependency(JpsJavaSdkType.INSTANCE);
}
} else if (INHERITED_JDK_TYPE.equals(type)) {
final JpsSdkType<?> sdkType = projectSdkType != null ? projectSdkType : JpsJavaSdkType.INSTANCE;
dependenciesList.addSdkDependency(sdkType);
if (sdkType instanceof JpsJavaSdkTypeWrapper) {
dependenciesList.addSdkDependency(JpsJavaSdkType.INSTANCE);
}
} else if (LIBRARY_TYPE.equals(type)) {
String name = orderEntry.getAttributeValue(NAME_ATTRIBUTE);
String level = orderEntry.getAttributeValue(LEVEL_ATTRIBUTE);
final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(elementFactory.createLibraryReference(name, JpsLibraryTableSerializer.createLibraryTableReference(level)));
loadModuleDependencyProperties(dependency, orderEntry);
} else if (MODULE_LIBRARY_TYPE.equals(type)) {
final Element moduleLibraryElement = orderEntry.getChild(LIBRARY_TAG);
String name = moduleLibraryElement.getAttributeValue(NAME_ATTRIBUTE);
if (name == null) {
name = GENERATED_LIBRARY_NAME_PREFIX;
}
String uniqueName = nameGenerator.generateUniqueName(name);
final JpsLibrary library = JpsLibraryTableSerializer.loadLibrary(moduleLibraryElement, uniqueName);
module.addModuleLibrary(library);
final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(library);
loadModuleDependencyProperties(dependency, orderEntry);
} else if (MODULE_TYPE.equals(type)) {
String name = orderEntry.getAttributeValue(MODULE_NAME_ATTRIBUTE);
final JpsModuleDependency dependency = dependenciesList.addModuleDependency(elementFactory.createModuleReference(name));
loadModuleDependencyProperties(dependency, orderEntry);
}
}
if (!moduleSourceAdded) {
dependenciesList.addModuleSourceDependency();
}
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
extension.loadRootModel(module, rootModelComponent);
}
}
use of org.jetbrains.jps.model.serialization.JpsModelSerializerExtension in project intellij-community by JetBrains.
the class JpsRunConfigurationSerializer method loadRunConfigurations.
public static void loadRunConfigurations(@NotNull JpsProject project, @Nullable Element runManagerTag) {
Map<String, JpsRunConfigurationPropertiesSerializer<?>> serializers = new HashMap<>();
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
for (JpsRunConfigurationPropertiesSerializer<?> serializer : extension.getRunConfigurationPropertiesSerializers()) {
serializers.put(serializer.getTypeId(), serializer);
}
}
for (Element configurationTag : JDOMUtil.getChildren(runManagerTag, "configuration")) {
if (Boolean.parseBoolean(configurationTag.getAttributeValue("default"))) {
continue;
}
String typeId = configurationTag.getAttributeValue("type");
JpsRunConfigurationPropertiesSerializer<?> serializer = serializers.get(typeId);
String name = configurationTag.getAttributeValue("name");
if (serializer != null) {
loadRunConfiguration(name, configurationTag, serializer, project);
} else if (typeId != null) {
project.addRunConfiguration(name, new JpsUnknownRunConfigurationType(typeId), JpsElementFactory.getInstance().createDummyElement());
} else {
LOG.info("Run configuration '" + name + "' wasn't loaded because 'type' attribute is missing");
}
}
}
use of org.jetbrains.jps.model.serialization.JpsModelSerializerExtension in project intellij-community by JetBrains.
the class JpsFacetSerializer method saveFacets.
public static void saveFacets(JpsModule module, @NotNull Element facetManagerElement) {
FacetManagerState managerState = new FacetManagerState();
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
for (JpsFacetConfigurationSerializer<?> serializer : extension.getFacetConfigurationSerializers()) {
if (serializer.hasExtension(module)) {
serializer.saveExtension(module, managerState.getFacets());
}
}
}
XmlSerializer.serializeInto(managerState, facetManagerElement, new SkipDefaultValuesSerializationFilters());
}
Aggregations