当前位置: 首页>>代码示例>>Java>>正文


Java JavaSourceRootProperties类代码示例

本文整理汇总了Java中org.jetbrains.jps.model.java.JavaSourceRootProperties的典型用法代码示例。如果您正苦于以下问题:Java JavaSourceRootProperties类的具体用法?Java JavaSourceRootProperties怎么用?Java JavaSourceRootProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JavaSourceRootProperties类属于org.jetbrains.jps.model.java包,在下文中一共展示了JavaSourceRootProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEnabled

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@Override
protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
  if (!isJavaModule(module)) return false;

  if (selection.myHaveSelectedFilesUnderSourceRoots) {
    return false;
  }

  if (!selection.mySelectedDirectories.isEmpty()) {
    return true;
  }

  for (SourceFolder root : selection.mySelectedRoots) {
    JavaSourceRootProperties properties = root.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    if (properties != null && !properties.isForGeneratedSources()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MarkGeneratedSourceRootAction.java

示例2: markRootAsGenerated

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
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;
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:AndroidCompileUtil.java

示例3: testMarkSourcesAsGeneratedOnReImport

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
public void testMarkSourcesAsGeneratedOnReImport() throws IOException {
  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>");
  new File(myProjectRoot.getPath(), "target/generated-sources/xxx/z").mkdirs();
  updateProjectFolders();

  assertGeneratedSources("project", "target/generated-sources/xxx");

  ModuleRootModificationUtil.updateModel(getModule("project"), new Consumer<ModifiableRootModel>() {
    @Override
    public void consume(ModifiableRootModel model) {
      for (SourceFolder folder : model.getContentEntries()[0].getSourceFolders()) {
        JavaSourceRootProperties properties = folder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
        assertNotNull(properties);
        properties.setForGeneratedSources(false);
      }
    }
  });
  assertGeneratedSources("project");

  importProject();
  assertGeneratedSources("project", "target/generated-sources/xxx");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:MavenFoldersImporterTest.java

示例4: setSourceFolderForLocation

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@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;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:21,代码来源:JavaSourceFolderProvider.java

示例5: computeRootDescriptors

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@NotNull
@Override
public List<ResourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
  List<ResourceRootDescriptor> roots = new ArrayList<ResourceRootDescriptor>();
  JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
  Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);

  roots_loop:
  for (JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> sourceRoot : myModule.getSourceRoots(type)) {
    for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
      if (provider.isExcludedFromCompilation(myModule, sourceRoot)) {
        continue roots_loop;
      }
    }
    final String packagePrefix = sourceRoot.getProperties().getData().getPackagePrefix();
    final File rootFile = sourceRoot.getFile();
    roots.add(new ResourceRootDescriptor(rootFile, this, false, packagePrefix, computeRootExcludes(rootFile, index)));
  }

  return roots;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:ResourcesTarget.java

示例6: testPackagePrefix

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
public void testPackagePrefix() {
  String file = createFile("src/a.xml");
  JpsModule m = addModule("m", PathUtil.getParentPath(file));
  JpsModuleSourceRoot sourceRoot = assertOneElement(m.getSourceRoots());
  JpsTypedModuleSourceRoot<JavaSourceRootProperties> typed = sourceRoot.asTyped(JavaSourceRootType.SOURCE);
  assertNotNull(typed);
  typed.getProperties().setPackagePrefix("xxx");
  rebuildAll();
  assertOutput(m, fs().dir("xxx").file("a.xml"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ResourceCopyingTest.java

示例7: isEnabled

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@Override
protected boolean isEnabled(@NotNull RootsSelection selection, @NotNull Module module) {
  for (SourceFolder root : selection.mySelectedRoots) {
    JavaSourceRootProperties properties = root.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    if (properties != null && properties.isForGeneratedSources()) {
      return true;
    }
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:UnmarkGeneratedSourceRootAction.java

示例8: testGeneratedSourceRoot

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
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));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AnalysisScopeTest.java

示例9: getJavaProperties

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@Nullable
private JavaSourceRootProperties getJavaProperties() {
  if (mySourceRoot.getRootType() == JavaSourceRootType.SOURCE) {
    return mySourceRoot.getProperties(JavaSourceRootType.SOURCE);
  }
  if (mySourceRoot.getRootType() == JavaSourceRootType.TEST_SOURCE) {
    return mySourceRoot.getProperties(JavaSourceRootType.TEST_SOURCE);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:JpsSourceFolder.java

示例10: setPackagePrefix

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@Override
public void setPackagePrefix(@NotNull String packagePrefix) {
  JavaSourceRootProperties properties = getJavaProperties();
  if (properties != null) {
    properties.setPackagePrefix(packagePrefix);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:JpsSourceFolder.java

示例11: createSourceRootIfAbsent

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
private static void createSourceRootIfAbsent(
  @NotNull ContentEntry entry, @NotNull final SourceRoot root, @NotNull String moduleName,
  @NotNull JpsModuleSourceRootType<?> sourceRootType, boolean generated, boolean createEmptyContentRootDirectories) {
  List<SourceFolder> folders = entry.getSourceFolders(sourceRootType);
  for (SourceFolder folder : folders) {
    VirtualFile file = folder.getFile();
    if (file == null) {
      continue;
    }
    if (ExternalSystemApiUtil.getLocalFileSystemPath(file).equals(root.getPath())) {
      return;
    }
  }
  LOG.debug(String.format("Importing %s for content root '%s' of module '%s'", root, entry.getUrl(), moduleName));
  SourceFolder sourceFolder = entry.addSourceFolder(toVfsUrl(root.getPath()), sourceRootType);
  if (!StringUtil.isEmpty(root.getPackagePrefix())) {
    sourceFolder.setPackagePrefix(root.getPackagePrefix());
  }
  if (generated) {
    JavaSourceRootProperties properties = sourceFolder.getJpsElement().getProperties(JavaModuleSourceRootTypes.SOURCES);
    if(properties != null) {
      properties.setForGeneratedSources(true);
    }
  }
  if(createEmptyContentRootDirectories) {
    ExternalSystemApiUtil.doWriteAction(new Runnable() {
      @Override
      public void run() {
        try {
          VfsUtil.createDirectoryIfMissing(root.getPath());
        }
        catch (IOException e) {
          LOG.warn(String.format("Unable to create directory for the path: %s", root.getPath()), e);
        }
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:ContentRootDataService.java

示例12: assertGeneratedSources

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
private void assertGeneratedSources(String moduleName, JavaSourceRootType type, String... expectedSources) {
  ContentEntry contentRoot = getContentRoot(moduleName);
  List<ContentFolder> folders = new ArrayList<ContentFolder>();
  for (SourceFolder folder : contentRoot.getSourceFolders(type)) {
    JavaSourceRootProperties properties = folder.getJpsElement().getProperties(type);
    assertNotNull(properties);
    if (properties.isForGeneratedSources()) {
      folders.add(folder);
    }
  }
  doAssertContentFolders(contentRoot, folders, expectedSources);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ExternalSystemImportingTestCase.java

示例13: getPresentablePrefix

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
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 "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ContentEntryTreeCellRenderer.java

示例14: getPropertiesString

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
@Nullable
@Override
public String getPropertiesString(@NotNull JavaSourceRootProperties properties) {
  StringBuilder buffer = new StringBuilder();
  if (properties.isForGeneratedSources()) {
    buffer.append(" [generated]");
  }
  String packagePrefix = properties.getPackagePrefix();
  if (!packagePrefix.isEmpty()) {
    buffer.append(" (").append(packagePrefix).append(")");
  }
  return buffer.length() > 0 ? buffer.toString() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:JavaSourceRootEditHandlerBase.java

示例15: SourceRootPropertiesDialog

import org.jetbrains.jps.model.java.JavaSourceRootProperties; //导入依赖的package包/类
private SourceRootPropertiesDialog(@NotNull JComponent parentComponent, @NotNull JavaSourceRootProperties properties) {
  super(parentComponent, true);
  myProperties = properties;
  setTitle(ProjectBundle.message("module.paths.edit.properties.title"));
  myPackagePrefixField = new JTextField();
  myIsGeneratedCheckBox = new JCheckBox(UIUtil.replaceMnemonicAmpersand("For &generated sources"));
  myMainPanel = FormBuilder.createFormBuilder()
    .addLabeledComponent("Package &prefix:", myPackagePrefixField)
    .addComponent(myIsGeneratedCheckBox)
    .getPanel();
  myPackagePrefixField.setText(myProperties.getPackagePrefix());
  myPackagePrefixField.setColumns(25);
  myIsGeneratedCheckBox.setSelected(myProperties.isForGeneratedSources());
  init();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaSourceRootEditHandlerBase.java


注:本文中的org.jetbrains.jps.model.java.JavaSourceRootProperties类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。