Search in sources :

Example 6 with JavaSourceRootProperties

use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-community by JetBrains.

the class JavaProjectRootsUtil method isForGeneratedSources.

public static boolean isForGeneratedSources(SourceFolder sourceFolder) {
    JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    JavaResourceRootProperties resourceProperties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.RESOURCES);
    return properties != null && properties.isForGeneratedSources() || resourceProperties != null && resourceProperties.isForGeneratedSources();
}
Also used : JavaResourceRootProperties(org.jetbrains.jps.model.java.JavaResourceRootProperties) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties)

Example 7 with JavaSourceRootProperties

use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-community by JetBrains.

the class ProjectViewDirectoryHelper method getLocationString.

@Nullable
public String getLocationString(@NotNull PsiDirectory psiDirectory, boolean includeUrl, boolean includeRootType) {
    StringBuilder result = new StringBuilder();
    final VirtualFile directory = psiDirectory.getVirtualFile();
    if (ProjectRootsUtil.isLibraryRoot(directory, psiDirectory.getProject())) {
        result.append(ProjectBundle.message("module.paths.root.node", "library").toLowerCase(Locale.getDefault()));
    } else if (includeRootType) {
        SourceFolder sourceRoot = ProjectRootsUtil.getModuleSourceRoot(psiDirectory.getVirtualFile(), psiDirectory.getProject());
        if (sourceRoot != null) {
            ModuleSourceRootEditHandler<?> handler = ModuleSourceRootEditHandler.getEditHandler(sourceRoot.getRootType());
            if (handler != null) {
                JavaSourceRootProperties properties = sourceRoot.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
                if (properties != null && properties.isForGeneratedSources()) {
                    result.append("generated ");
                }
                result.append(handler.getFullRootTypeName().toLowerCase(Locale.getDefault()));
            }
        }
    }
    if (includeUrl) {
        if (result.length() > 0)
            result.append(",").append(FontUtil.spaceAndThinSpace());
        result.append(FileUtil.getLocationRelativeToUserHome(directory.getPresentableUrl()));
    }
    return result.length() == 0 ? null : result.toString();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModuleSourceRootEditHandler(com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with JavaSourceRootProperties

use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project android by JetBrains.

the class ContentEntriesSetup method addSourceFolder.

private static void addSourceFolder(@NotNull ContentEntry contentEntry, @NotNull File folderPath, @NotNull JpsModuleSourceRootType type, boolean generated) {
    String url = pathToIdeaUrl(folderPath);
    SourceFolder sourceFolder = contentEntry.addSourceFolder(url, type);
    if (generated) {
        JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
        JpsElement properties = sourceRoot.getProperties();
        if (properties instanceof JavaSourceRootProperties) {
            ((JavaSourceRootProperties) properties).setForGeneratedSources(true);
        }
    }
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties)

Example 9 with JavaSourceRootProperties

use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-elixir by KronicDeth.

the class ElixirTarget method computeRootDescriptors.

@NotNull
@Override
public List<ElixirSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<ElixirSourceRootDescriptor> result = new ArrayList<ElixirSourceRootDescriptor>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> root : myModule.getSourceRoots(type)) {
        result.add(new ElixirSourceRootDescriptor(root.getFile(), this));
    }
    return result;
}
Also used : JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with JavaSourceRootProperties

use of org.jetbrains.jps.model.java.JavaSourceRootProperties in project intellij-community by JetBrains.

the class ContentEntryTreeCellRenderer method getPresentablePrefix.

private static String getPresentablePrefix(final ContentEntry entry, final VirtualFile file) {
    for (final SourceFolder sourceFolder : entry.getSourceFolders()) {
        if (file.equals(sourceFolder.getFile())) {
            JpsModuleSourceRoot element = sourceFolder.getJpsElement();
            JavaSourceRootProperties properties = element.getProperties(JavaModuleSourceRootTypes.SOURCES);
            if (properties != null)
                return properties.getPackagePrefix();
            JavaResourceRootProperties resourceRootProperties = element.getProperties(JavaModuleSourceRootTypes.RESOURCES);
            if (resourceRootProperties != null)
                return resourceRootProperties.getRelativeOutputPath();
        }
    }
    return "";
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JavaResourceRootProperties(org.jetbrains.jps.model.java.JavaResourceRootProperties) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties)

Aggregations

JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)17 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 SourceFolder (com.intellij.openapi.roots.SourceFolder)3 JavaSourceRootType (org.jetbrains.jps.model.java.JavaSourceRootType)3 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)3 Nullable (org.jetbrains.annotations.Nullable)2 JpsElement (org.jetbrains.jps.model.JpsElement)2 JavaResourceRootProperties (org.jetbrains.jps.model.java.JavaResourceRootProperties)2 AnalysisScope (com.intellij.analysis.AnalysisScope)1 ModuleSourceRootEditHandler (com.intellij.openapi.roots.ui.configuration.ModuleSourceRootEditHandler)1 JpsContentEntry (com.intellij.project.model.impl.module.content.JpsContentEntry)1 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)1 IconActionComponent (com.intellij.ui.roots.IconActionComponent)1 File (java.io.File)1 IOException (java.io.IOException)1 NotNull (org.jetbrains.annotations.NotNull)1 Url (org.jetbrains.idea.maven.utils.Url)1 JpsElementBase (org.jetbrains.jps.model.ex.JpsElementBase)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1