use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class MavenSourceFoldersModuleExtension method init.
public void init(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel) {
myRootModel = modifiableRootModel;
myDummyJpsModule = JpsElementFactory.getInstance().createModule(module.getName(), JpsJavaModuleType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
myDummyJpsRootModel = new JpsRootModel(module, myDummyJpsModule);
for (JpsSourceFolder folder : myJpsSourceFolders) {
Disposer.dispose(folder);
}
myJpsSourceFolders.clear();
for (ContentEntry eachEntry : modifiableRootModel.getContentEntries()) {
for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
//noinspection unchecked
final JpsModuleSourceRoot jpsModuleSourceRoot = JpsElementFactory.getInstance().createModuleSourceRoot(eachFolder.getUrl(), (JpsModuleSourceRootType<JpsElement>) eachFolder.getRootType(), eachFolder.getJpsElement().getProperties().getBulkModificationSupport().createCopy());
addJspSourceFolder(jpsModuleSourceRoot, eachFolder.getUrl());
}
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsContentEntry method addSourceFolder.
@NotNull
public <P extends JpsElement> SourceFolder addSourceFolder(@NotNull String url, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties) {
final JpsModuleSourceRoot sourceRoot = myModule.addSourceRoot(url, type, properties);
final JpsSourceFolder sourceFolder = new JpsSourceFolder(sourceRoot, this);
mySourceFolders.add(sourceFolder);
return sourceFolder;
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsContentEntry method clearSourceFolders.
@Override
public void clearSourceFolders() {
List<JpsModuleSourceRoot> toRemove = new ArrayList<>();
for (JpsSourceFolder folder : mySourceFolders) {
toRemove.add(folder.getSourceRoot());
Disposer.dispose(folder);
}
mySourceFolders.clear();
for (JpsModuleSourceRoot root : toRemove) {
myModule.removeSourceRoot(root.getUrl(), root.getRootType());
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsContentEntry method addSourceFolder.
@NotNull
@Override
public <P extends JpsElement> SourceFolder addSourceFolder(@NotNull VirtualFile file, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties) {
final JpsModuleSourceRoot sourceRoot = myModule.addSourceRoot(file.getUrl(), type, properties);
final JpsSourceFolder sourceFolder = new JpsSourceFolder(sourceRoot, this);
mySourceFolders.add(sourceFolder);
return sourceFolder;
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.
the class JpsIdeaSpecificSettings method readContentEntry.
@Override
public void readContentEntry(Element root, String contentUrl, JpsModule model) {
for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
final String url = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
JpsModuleSourceRoot folderToBeTest = null;
for (JpsModuleSourceRoot folder : model.getSourceRoots()) {
if (Comparing.strEqual(folder.getUrl(), url)) {
folderToBeTest = folder;
break;
}
}
if (folderToBeTest != null) {
model.removeSourceRoot(folderToBeTest.getUrl(), JavaSourceRootType.SOURCE);
}
model.addSourceRoot(url, JavaSourceRootType.TEST_SOURCE);
}
for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
final String excludeUrl = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
if (FileUtil.isAncestor(new File(contentUrl), new File(excludeUrl), false)) {
model.getExcludeRootsList().addUrl(excludeUrl);
}
}
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
Element ppElement = (Element) o;
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
for (JpsModuleSourceRoot sourceRoot : model.getSourceRoots()) {
if (Comparing.strEqual(sourceRoot.getUrl(), url)) {
JpsElement properties = sourceRoot.getProperties();
if (properties instanceof JavaSourceRootProperties) {
((JavaSourceRootProperties) properties).setPackagePrefix(prefix);
}
break;
}
}
}
}
Aggregations