org.jetbrains.jps.model.java.JavaSourceRootProperties Java Examples

The following examples show how to use org.jetbrains.jps.model.java.JavaSourceRootProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavaSourceFolderProvider.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Override
public SourceFolder setSourceFolderForLocation(
    ContentEntry contentEntry, SourceFolder parentFolder, File file, boolean isTestSource) {
  SourceFolder sourceFolder;
  if (isResource(parentFolder)) {
    JavaResourceRootType resourceRootType =
        isTestSource ? JavaResourceRootType.TEST_RESOURCE : JavaResourceRootType.RESOURCE;
    sourceFolder =
        contentEntry.addSourceFolder(UrlUtil.pathToUrl(file.getPath()), resourceRootType);
  } else {
    sourceFolder = contentEntry.addSourceFolder(UrlUtil.pathToUrl(file.getPath()), isTestSource);
  }
  sourceFolder.setPackagePrefix(derivePackagePrefix(file, parentFolder));
  JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
  JpsElement properties = sourceRoot.getProperties();
  if (properties instanceof JavaSourceRootProperties) {
    ((JavaSourceRootProperties) properties).setForGeneratedSources(isGenerated(parentFolder));
  }
  return sourceFolder;
}
 
Example #2
Source File: MavenImportingTestCase.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
protected void assertGeneratedSources(String moduleName, String... expectedSources) {
  ContentEntry contentRoot = getContentRoot(moduleName);
  List<ContentFolder> folders = new ArrayList<>();
  for (SourceFolder folder : contentRoot.getSourceFolders(JavaSourceRootType.SOURCE)) {
    JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaSourceRootType.SOURCE);
    assertNotNull(properties);
    if (properties.isForGeneratedSources()) {
      folders.add(folder);
    }
  }
  doAssertContentFolders(contentRoot, folders, expectedSources);
}
 
Example #3
Source File: JavaSourceFolderProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static SourceFolder addSourceFolderToContentEntry(
    ContentEntry contentEntry, BlazeSourceDirectory sourceDirectory) {
  File sourceDir = sourceDirectory.getDirectory();

  // Create the source folder
  SourceFolder sourceFolder;
  if (sourceDirectory.isResource()) {
    sourceFolder =
        contentEntry.addSourceFolder(
            UrlUtil.pathToUrl(sourceDir.getPath()), JavaResourceRootType.RESOURCE);
  } else {
    sourceFolder = contentEntry.addSourceFolder(UrlUtil.pathToUrl(sourceDir.getPath()), false);
  }
  JpsModuleSourceRoot sourceRoot = sourceFolder.getJpsElement();
  JpsElement properties = sourceRoot.getProperties();
  if (properties instanceof JavaSourceRootProperties) {
    JavaSourceRootProperties rootProperties = (JavaSourceRootProperties) properties;
    if (sourceDirectory.isGenerated()) {
      rootProperties.setForGeneratedSources(true);
    }
  }
  String packagePrefix = sourceDirectory.getPackagePrefix();
  if (!Strings.isNullOrEmpty(packagePrefix)) {
    sourceFolder.setPackagePrefix(packagePrefix);
  }
  return sourceFolder;
}
 
Example #4
Source File: HaskellTarget.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
@NotNull
@Override
public List<HaskellSourceRootDescriptor> computeRootDescriptors(JpsModel jpsModel, ModuleExcludeIndex moduleExcludeIndex, IgnoredFileIndex ignoredFileIndex, BuildDataPaths buildDataPaths) {
    List<HaskellSourceRootDescriptor> result = new ArrayList<HaskellSourceRootDescriptor>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> root : myModule.getSourceRoots(type)) {
        result.add(new HaskellSourceRootDescriptor(root.getFile(), this));
    }
    return result;
}
 
Example #5
Source File: JavaSourceFolderProvider.java    From intellij with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting
static boolean isGenerated(SourceFolder folder) {
  JpsElement properties = folder.getJpsElement().getProperties();
  return properties instanceof JavaSourceRootProperties
      && ((JavaSourceRootProperties) properties).isForGeneratedSources();
}