use of com.intellij.configurationStore.UnknownElementCollector in project intellij-community by JetBrains.
the class CodeStyleSettings method readExternal.
@Override
public void readExternal(Element element) throws InvalidDataException {
DefaultJDOMExternalizer.readExternal(this, element);
if (LAYOUT_STATIC_IMPORTS_SEPARATELY) {
// add <all other static imports> entry if there is none
boolean found = false;
for (PackageEntry entry : IMPORT_LAYOUT_TABLE.getEntries()) {
if (entry == PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY) {
found = true;
break;
}
}
if (!found) {
PackageEntry last = IMPORT_LAYOUT_TABLE.getEntryCount() == 0 ? null : IMPORT_LAYOUT_TABLE.getEntryAt(IMPORT_LAYOUT_TABLE.getEntryCount() - 1);
if (last != PackageEntry.BLANK_LINE_ENTRY) {
IMPORT_LAYOUT_TABLE.addEntry(PackageEntry.BLANK_LINE_ENTRY);
}
IMPORT_LAYOUT_TABLE.addEntry(PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY);
}
}
myRepeatAnnotations.clear();
Element annotations = element.getChild(REPEAT_ANNOTATIONS);
if (annotations != null) {
for (Element anno : annotations.getChildren("ANNO")) {
myRepeatAnnotations.add(anno.getAttributeValue("name"));
}
}
UnknownElementCollector unknownElementCollector = new UnknownElementCollector();
for (CustomCodeStyleSettings settings : getCustomSettingsValues()) {
settings.getKnownTagNames().forEach(unknownElementCollector::addKnownName);
settings.readExternal(element);
}
unknownElementCollector.addKnownName(ADDITIONAL_INDENT_OPTIONS);
List<Element> list = element.getChildren(ADDITIONAL_INDENT_OPTIONS);
for (Element additionalIndentElement : list) {
String fileTypeId = additionalIndentElement.getAttributeValue(FILETYPE);
if (!StringUtil.isEmpty(fileTypeId)) {
FileType target = FileTypeManager.getInstance().getFileTypeByExtension(fileTypeId);
if (FileTypes.UNKNOWN == target || FileTypes.PLAIN_TEXT == target || target.getDefaultExtension().isEmpty()) {
target = new TempFileType(fileTypeId);
}
IndentOptions options = getDefaultIndentOptions(target);
options.readExternal(additionalIndentElement);
registerAdditionalIndentOptions(target, options);
}
}
unknownElementCollector.addKnownName(CommonCodeStyleSettingsManager.COMMON_SETTINGS_TAG);
myCommonSettingsManager.readExternal(element);
myUnknownElementWriter = unknownElementCollector.createWriter(element);
if (USE_SAME_INDENTS) {
IGNORE_SAME_INDENTS_FOR_LANGUAGES = true;
}
}
Aggregations