use of org.jetbrains.jps.model.module.JpsModuleSourceRootType 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;
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRootType in project android by JetBrains.
the class IdeFrameFixture method getSourceFolderRelativePaths.
/**
* Returns a list of system independent paths
*/
@NotNull
public Collection<String> getSourceFolderRelativePaths(@NotNull String moduleName, @NotNull JpsModuleSourceRootType<?> sourceType) {
Set<String> paths = Sets.newHashSet();
Module module = getModule(moduleName);
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
execute(new GuiTask() {
@Override
protected void executeInEDT() throws Throwable {
ModifiableRootModel rootModel = moduleRootManager.getModifiableModel();
try {
for (ContentEntry contentEntry : rootModel.getContentEntries()) {
for (SourceFolder folder : contentEntry.getSourceFolders()) {
JpsModuleSourceRootType<?> rootType = folder.getRootType();
if (rootType.equals(sourceType)) {
String path = urlToPath(folder.getUrl());
String relativePath = getRelativePath(myProjectPath, new File(toSystemDependentName(path)));
paths.add(PathUtil.toSystemIndependentName(relativePath));
}
}
}
} finally {
rootModel.dispose();
}
}
});
return paths;
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRootType in project android by JetBrains.
the class AndroidContentEntriesSetup method addGeneratedSourceFolders.
private void addGeneratedSourceFolders(@NotNull BaseArtifact artifact, @NotNull List<ContentEntry> contentEntries, boolean isTest) {
JpsModuleSourceRootType sourceType = getSourceType(isTest);
GradleVersion modelVersion = myAndroidModel.getModelVersion();
if (artifact instanceof AndroidArtifact || (modelVersion != null && modelVersion.compareIgnoringQualifiers("1.2") >= 0)) {
// getGeneratedSourceFolders used to be in AndroidArtifact only.
Collection<File> generatedSourceFolders = getGeneratedSourceFolders(artifact);
//noinspection ConstantConditions - this returned null in 1.2
if (generatedSourceFolders != null) {
addSourceFolders(generatedSourceFolders, contentEntries, sourceType, true);
}
}
if (artifact instanceof AndroidArtifact) {
sourceType = getResourceSourceType(isTest);
AndroidArtifact androidArtifact = (AndroidArtifact) artifact;
addSourceFolders(androidArtifact.getGeneratedResourceFolders(), contentEntries, sourceType, true);
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRootType in project intellij-community by JetBrains.
the class ContentRootPanel method addFolderGroupComponents.
protected void addFolderGroupComponents() {
final SourceFolder[] sourceFolders = getContentEntry().getSourceFolders();
MultiMap<JpsModuleSourceRootType<?>, SourceFolder> folderByType = new MultiMap<>();
for (SourceFolder folder : sourceFolders) {
if (!folder.isSynthetic()) {
folderByType.putValue(folder.getRootType(), folder);
}
}
Insets insets = JBUI.insetsBottom(10);
GridBagConstraints constraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, insets, 0, 0);
for (ModuleSourceRootEditHandler<?> editor : myModuleSourceRootEditHandlers) {
Collection<SourceFolder> folders = folderByType.get(editor.getRootType());
if (folders.isEmpty())
continue;
ContentFolder[] foldersArray = folders.toArray(new ContentFolder[folders.size()]);
final JComponent sourcesComponent = createFolderGroupComponent(editor.getRootsGroupTitle(), foldersArray, editor.getRootsGroupColor(), editor);
add(sourcesComponent, constraints);
}
ExcludeFolder[] excluded = getContentEntry().getExcludeFolders();
if (excluded.length > 0) {
final JComponent excludedComponent = createFolderGroupComponent(ProjectBundle.message("module.paths.excluded.group"), excluded, EXCLUDED_COLOR, null);
this.add(excludedComponent, constraints);
}
}
use of org.jetbrains.jps.model.module.JpsModuleSourceRootType in project android by JetBrains.
the class AndroidContentEntriesSetup method addSourceFolder.
private void addSourceFolder(@NotNull SourceProvider sourceProvider, @NotNull List<ContentEntry> contentEntries, boolean isTest) {
JpsModuleSourceRootType sourceType = getResourceSourceType(isTest);
addSourceFolders(sourceProvider.getResDirectories(), contentEntries, sourceType, false);
addSourceFolders(sourceProvider.getResourcesDirectories(), contentEntries, sourceType, false);
addSourceFolders(sourceProvider.getAssetsDirectories(), contentEntries, sourceType, false);
sourceType = getSourceType(isTest);
addSourceFolders(sourceProvider.getAidlDirectories(), contentEntries, sourceType, false);
addSourceFolders(sourceProvider.getJavaDirectories(), contentEntries, sourceType, false);
if (myHasNativeModel) {
addSourceFolders(sourceProvider.getCDirectories(), contentEntries, sourceType, false);
addSourceFolders(sourceProvider.getCppDirectories(), contentEntries, sourceType, false);
}
addSourceFolders(sourceProvider.getRenderscriptDirectories(), contentEntries, sourceType, false);
if (myAndroidModel.getFeatures().isShadersSupported()) {
addSourceFolders(sourceProvider.getShadersDirectories(), contentEntries, sourceType, false);
}
}
Aggregations