org.jetbrains.jps.model.JpsElement Java Examples

The following examples show how to use org.jetbrains.jps.model.JpsElement. 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: ThriftFacetConfigurationSerializer.java    From intellij-thrift with Apache License 2.0 6 votes vote down vote up
@Override
protected ThriftCompilerOptions loadExtension(@NotNull Element facetConfigurationElement,
                                              String name,
                                              JpsElement parent,
                                              JpsModule module) {
  ThriftCompilerOptions configuration = XmlSerializer.deserialize(
    facetConfigurationElement,
    ThriftCompilerOptions.class
  );

  if (configuration == null) {
    configuration = new ThriftCompilerOptions();
  }

  return configuration;
}
 
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: 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();
}
 
Example #5
Source File: JpsHaxeUtil.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@Nullable
public static JpsHaxeModuleSettings getModuleSettings(@NotNull JpsModule module) {
  final JpsElement result = module.getProperties();
  return result instanceof JpsHaxeModuleSettings ? (JpsHaxeModuleSettings)result : null;
}