use of org.jetbrains.jps.model.ex.JpsElementBase in project intellij-community by JetBrains.
the class MavenSourceFoldersModuleExtension method commit.
@Override
public void commit() {
if (!isJpsSourceFoldersChanged)
return;
for (ContentEntry eachEntry : myRootModel.getContentEntries()) {
for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
boolean found = false;
for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
if (StringUtil.equals(jpsSourceFolder.getUrl(), eachFolder.getUrl()) && eachFolder.getRootType().equals(jpsSourceFolder.getRootType())) {
found = true;
if (eachFolder.getRootType() instanceof JavaSourceRootType) {
final JavaSourceRootProperties jpsJavaSourceRootProperties = jpsSourceFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
final JavaSourceRootProperties javaSourceRootProperties = eachFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
if (javaSourceRootProperties != null && jpsJavaSourceRootProperties != null) {
javaSourceRootProperties.applyChanges(jpsJavaSourceRootProperties);
}
}
myJpsSourceFolders.remove(jpsSourceFolder);
Disposer.dispose(jpsSourceFolder);
break;
}
}
if (!found) {
eachEntry.removeSourceFolder(eachFolder);
}
}
}
for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
Url url = new Url(jpsSourceFolder.getUrl());
ContentEntry e = getContentRootFor(url);
if (e == null)
continue;
//noinspection unchecked
JpsModuleSourceRootType<JpsElement> sourceRootType = (JpsModuleSourceRootType<JpsElement>) jpsSourceFolder.getRootType();
final JpsElementBase properties = (JpsElementBase) jpsSourceFolder.getSourceRoot().getProperties();
//noinspection unchecked
properties.setParent(null);
e.addSourceFolder(url.getUrl(), sourceRootType, properties);
}
isJpsSourceFoldersChanged = false;
}
Aggregations