use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class ProjectRootContainerImpl method readOldVersion.
@SuppressWarnings({ "HardCodedStringLiteral" })
void readOldVersion(Element child) {
for (Element root : child.getChildren("root")) {
String url = root.getAttributeValue("file");
SimpleProjectRoot projectRoot = new SimpleProjectRoot(url);
String type = root.getChild("property").getAttributeValue("value");
for (PersistentOrderRootType rootType : OrderRootType.getAllPersistentTypes()) {
if (type.equals(rootType.getOldSdkRootName())) {
addRoot(projectRoot, rootType);
break;
}
}
}
myFiles = new HashMap<>();
for (OrderRootType rootType : myRoots.keySet()) {
myFiles.put(rootType, myRoots.get(rootType).getVirtualFiles());
}
for (OrderRootType type : OrderRootType.getAllTypes()) {
final VirtualFile[] oldRoots = VirtualFile.EMPTY_ARRAY;
final VirtualFile[] newRoots = getRootFiles(type);
if (!Comparing.equal(oldRoots, newRoots)) {
fireRootsChanged();
break;
}
}
}
use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class ProjectRootContainerImpl method finishChange.
@Override
public void finishChange() {
LOG.assertTrue(myInsideChange);
HashMap<OrderRootType, VirtualFile[]> oldRoots = new HashMap<>(myFiles);
boolean changes = false;
for (OrderRootType orderRootType : OrderRootType.getAllTypes()) {
final VirtualFile[] roots = myRoots.get(orderRootType).getVirtualFiles();
changes = changes || !Comparing.equal(roots, oldRoots.get(orderRootType));
myFiles.put(orderRootType, roots);
}
if (changes) {
fireRootsChanged();
}
myInsideChange = false;
}
use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class JarDirectories method readExternal.
@Override
public void readExternal(Element element) throws InvalidDataException {
clear();
final List<Element> jarDirs = element.getChildren(JAR_DIRECTORY_ELEMENT);
for (Element jarDir : jarDirs) {
final String url = jarDir.getAttributeValue(URL_ATTR);
final String recursive = jarDir.getAttributeValue(RECURSIVE_ATTR);
final OrderRootType rootType = getJarDirectoryRootType(jarDir.getAttributeValue(ROOT_TYPE_ATTR));
if (url != null) {
add(rootType, url, Boolean.valueOf(Boolean.parseBoolean(recursive)));
}
}
}
use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class LibraryImpl method initRoots.
private Map<OrderRootType, VirtualFilePointerContainer> initRoots() {
Disposer.register(this, myPointersDisposable);
Map<OrderRootType, VirtualFilePointerContainer> result = new HashMap<>(4);
for (OrderRootType rootType : getAllRootTypes()) {
result.put(rootType, VirtualFilePointerManager.getInstance().createContainer(myPointersDisposable));
}
return result;
}
use of com.intellij.openapi.roots.OrderRootType in project intellij-community by JetBrains.
the class LibraryImpl method writeExternal.
@Override
public void writeExternal(Element rootElement) {
checkDisposed();
Element element = new Element(ELEMENT);
if (myName != null) {
element.setAttribute(LIBRARY_NAME_ATTR, myName);
}
if (myKind != null) {
element.setAttribute(LIBRARY_TYPE_ATTR, myKind.getKindId());
LOG.assertTrue(myProperties != null, "Properties is 'null' in library with kind " + myKind);
final Object state = myProperties.getState();
if (state != null) {
final Element propertiesElement = XmlSerializer.serializeIfNotDefault(state, SERIALIZATION_FILTERS);
if (!JDOMUtil.isEmpty(propertiesElement)) {
element.addContent(propertiesElement.setName(PROPERTIES_ELEMENT));
}
}
}
ArrayList<OrderRootType> storableRootTypes = new ArrayList<>();
storableRootTypes.addAll(Arrays.asList(OrderRootType.getAllTypes()));
if (myKind != null) {
storableRootTypes.addAll(Arrays.asList(myKind.getAdditionalRootTypes()));
}
for (OrderRootType rootType : sortRootTypes(storableRootTypes)) {
final VirtualFilePointerContainer roots = myRoots.get(rootType);
if (roots.size() == 0 && rootType.skipWriteIfEmpty()) {
//compatibility iml/ipr
continue;
}
final Element rootTypeElement = new Element(rootType.name());
roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT);
element.addContent(rootTypeElement);
}
if (myExcludedRoots != null && myExcludedRoots.size() > 0) {
Element excluded = new Element(EXCLUDED_ROOTS_TAG);
myExcludedRoots.writeExternal(excluded, ROOT_PATH_ELEMENT);
element.addContent(excluded);
}
myJarDirectories.writeExternal(element);
rootElement.addContent(element);
}
Aggregations