Пример #1
0
  private void geppettoValidation(Collection<File> moduleLocations, Diagnostic result)
      throws IOException {

    Collection<File> importedModuleLocations = null;
    List<Metadata> metadatas = new ArrayList<Metadata>();
    for (File moduleRoot : moduleLocations) {
      Metadata md = getModuleMetadata(moduleRoot, result);
      if (md != null) metadatas.add(md);
    }

    if (result.getSeverity() == Diagnostic.ERROR) return;

    if (checkModuleSemantics) {
      File importedModulesDir = new File(getBuildDir(), IMPORTED_MODULES_ROOT);
      importedModuleLocations =
          getForge().downloadDependencies(metadatas, importedModulesDir, result);
    }
    if (importedModuleLocations == null) importedModuleLocations = Collections.emptyList();

    RubyHelper.setRubyServicesFactory(JRubyServices.FACTORY);
    ValidationOptions options = getValidationOptions(moduleLocations, importedModuleLocations);
    new PPDiagnosticsSetup(complianceLevel, options.getProblemsAdvisor())
        .createInjectorAndDoEMFRegistration();

    getValidationService()
        .validate(
            result,
            getModulesDir(),
            options,
            importedModuleLocations.toArray(new File[importedModuleLocations.size()]),
            new NullProgressMonitor());
  }
Пример #2
0
  private ValidationOptions getValidationOptions(
      Collection<File> moduleLocations, Collection<File> importedModuleLocations) {
    ValidationOptions options = new ValidationOptions();
    options.setCheckLayout(checkLayout);
    options.setCheckModuleSemantics(checkModuleSemantics);
    options.setCheckReferences(checkReferences);

    if (moduleLocations.size() == 1 && getModulesDir().equals(moduleLocations.iterator().next()))
      options.setFileType(FileType.MODULE_ROOT);
    else options.setFileType(FileType.PUPPET_ROOT);
    options.setPlatformURI(
        PuppetTarget.forComplianceLevel(complianceLevel, false).getPlatformURI());
    options.setEncodingProvider(
        new IEncodingProvider() {
          public String getEncoding(URI file) {
            return UTF_8.name();
          }
        });

    options.setSearchPath(getSearchPath(moduleLocations, importedModuleLocations));
    options.setProblemsAdvisor(potentialProblemsAdvisor);
    return options;
  }