use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class ContentEntryImpl method writeExternal.
public void writeExternal(@NotNull Element element) throws WriteExternalException {
assert !isDisposed();
LOG.assertTrue(ELEMENT_NAME.equals(element.getName()));
element.setAttribute(URL_ATTRIBUTE, myRoot.getUrl());
for (final SourceFolder sourceFolder : mySourceFolders) {
if (sourceFolder instanceof SourceFolderImpl) {
JpsModuleRootModelSerializer.saveSourceRoot(element, sourceFolder.getUrl(), sourceFolder.getJpsElement().asTyped());
}
}
for (final ExcludeFolder excludeFolder : myExcludeFolders) {
if (excludeFolder instanceof ExcludeFolderImpl) {
final Element subElement = new Element(ExcludeFolderImpl.ELEMENT_NAME);
((ExcludeFolderImpl) excludeFolder).writeExternal(subElement);
element.addContent(subElement);
}
}
}
use of com.intellij.openapi.roots.SourceFolder in project intellij-community by JetBrains.
the class PluginModuleType method getPluginXml.
@Nullable
public static XmlFile getPluginXml(Module module) {
if (module == null)
return null;
if (!isOfType(module)) {
for (final ContentEntry entry : ModuleRootManager.getInstance(module).getContentEntries()) {
for (final SourceFolder folder : entry.getSourceFolders(JavaModuleSourceRootTypes.PRODUCTION)) {
final VirtualFile file = folder.getFile();
if (file == null)
continue;
final String packagePrefix = folder.getPackagePrefix();
final String prefixPath = packagePrefix.isEmpty() ? "" : packagePrefix.replace('.', '/') + '/';
final String relativePath = prefixPath + PluginDescriptorConstants.PLUGIN_XML_PATH;
final VirtualFile pluginXmlVF = file.findFileByRelativePath(relativePath);
if (pluginXmlVF != null) {
final PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(pluginXmlVF);
if (psiFile instanceof XmlFile) {
return (XmlFile) psiFile;
}
}
}
}
return null;
}
final PluginBuildConfiguration buildConfiguration = PluginBuildConfiguration.getInstance(module);
if (buildConfiguration == null)
return null;
final ConfigFile configFile = buildConfiguration.getPluginXmlConfigFile();
return configFile != null ? configFile.getXmlFile() : null;
}
use of com.intellij.openapi.roots.SourceFolder in project android by JetBrains.
the class AddAndroidActivityPath method getSourceDirectoryPackagePrefix.
/**
* Returns the package prefix of the module's content root if it can be found.
*/
@NotNull
private static String getSourceDirectoryPackagePrefix(@NotNull Module module, File javaDir) {
VirtualFile javaVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(javaDir);
if (javaVirtualFile == null) {
return "";
}
SourceFolder sourceFolder = ProjectRootsUtil.findSourceFolder(module, javaVirtualFile);
if (sourceFolder == null) {
return "";
}
return sourceFolder.getPackagePrefix();
}
use of com.intellij.openapi.roots.SourceFolder in project android by JetBrains.
the class NonAndroidModuleNode method getNonEmptySourceTypes.
private static Set<NonAndroidSourceType> getNonEmptySourceTypes(Module module) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
Set<NonAndroidSourceType> sourceTypes = Sets.newHashSetWithExpectedSize(NonAndroidSourceType.values().length);
ContentEntry[] contentEntries = rootManager.getContentEntries();
for (ContentEntry entry : contentEntries) {
for (NonAndroidSourceType type : NonAndroidSourceType.values()) {
for (SourceFolder sourceFolder : entry.getSourceFolders(type.rootType)) {
if (sourceFolder.getFile() != null) {
sourceTypes.add(type);
break;
}
}
}
}
return sourceTypes;
}
use of com.intellij.openapi.roots.SourceFolder in project android by JetBrains.
the class ExcludedRoots method addFolderPathsFromExcludedModules.
private void addFolderPathsFromExcludedModules() {
for (Module module : myExcludedModules) {
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
for (ContentEntry entry : rootManager.getContentEntries()) {
for (SourceFolder sourceFolder : entry.getSourceFolders()) {
myExcludedRoots.add(urlToFilePath(sourceFolder.getUrl()));
}
CompilerModuleExtension compiler = rootManager.getModuleExtension(CompilerModuleExtension.class);
String url = compiler.getCompilerOutputUrl();
if (isNotEmpty(url)) {
myExcludedRoots.add(urlToFilePath(url));
}
}
AndroidModuleModel androidModuleModel = AndroidModuleModel.get(module);
if (androidModuleModel != null) {
myExcludedRoots.add(androidModuleModel.getMainArtifact().getJavaResourcesFolder());
}
}
}
Aggregations