use of org.jetbrains.jps.model.java.JavaSourceRootProperties 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.java.JavaSourceRootProperties in project intellij-community by JetBrains.
the class MarkGeneratedSourceRootAction method modifyRoots.
@Override
protected void modifyRoots(@NotNull VirtualFile vFile, @NotNull ContentEntry entry) {
JavaSourceRootProperties properties = JpsJavaExtensionService.getInstance().createSourceRootProperties("", true);
entry.addSourceFolder(vFile, JavaSourceRootType.SOURCE, properties);
}
use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-community by JetBrains.
the class AnalysisScopeTest method testGeneratedSourceRoot.
public void testGeneratedSourceRoot() throws Exception {
VirtualFile genRoot = getVirtualFile(createTempDir("genSrcRoot"));
VirtualFile srcRoot = getVirtualFile(createTempDir("srcRoot"));
JavaSourceRootProperties properties = JpsJavaExtensionService.getInstance().createSourceRootProperties("", true);
PsiTestUtil.addSourceRoot(myModule, genRoot, JavaSourceRootType.SOURCE, properties);
PsiTestUtil.addSourceRoot(myModule, srcRoot);
VirtualFile genClass = VfsTestUtil.createFile(genRoot, "Gen.java", "class Gen{}");
VirtualFile srcClass = VfsTestUtil.createFile(srcRoot, "Src.java", "class Src{}");
AnalysisScope scope = new AnalysisScope(myModule);
assertTrue(scope.contains(srcClass));
assertFalse(scope.contains(genClass));
}
use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project android by JetBrains.
the class AndroidCompileUtil method markRootAsGenerated.
private static void markRootAsGenerated(ModifiableRootModel model, VirtualFile root, Ref<Boolean> modelChangedFlag) {
final ContentEntry contentEntry = findContentEntryForRoot(model, root);
if (contentEntry == null) {
return;
}
for (SourceFolder sourceFolder : contentEntry.getSourceFolders()) {
if (root.equals(sourceFolder.getFile())) {
final JavaSourceRootProperties props = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
if (props != null) {
props.setForGeneratedSources(true);
modelChangedFlag.set(true);
break;
}
}
}
}
use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-community by JetBrains.
the class JavaSourceRootEditHandlerBase method createPropertiesEditor.
@Nullable
@Override
public JComponent createPropertiesEditor(@NotNull final SourceFolder folder, @NotNull final JComponent parentComponent, @NotNull final ContentRootPanel.ActionCallback callback) {
final IconActionComponent iconComponent = new IconActionComponent(AllIcons.Modules.SetPackagePrefix, AllIcons.Modules.SetPackagePrefixRollover, ProjectBundle.message("module.paths.edit.properties.tooltip"), () -> {
JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
assert properties != null;
SourceRootPropertiesDialog dialog = new SourceRootPropertiesDialog(parentComponent, properties);
if (dialog.showAndGet()) {
callback.onSourceRootPropertiesChanged(folder);
}
});
final JPanel panel = new JPanel(new BorderLayout());
panel.setOpaque(false);
panel.add(iconComponent, BorderLayout.CENTER);
panel.add(Box.createHorizontalStrut(3), BorderLayout.EAST);
return panel;
}
Aggregations