Beispiel #1
0
 public ModuleDescriptor loadModuleDescriptor(IFile file) {
   try {
     String filePath = file.getPath();
     if (filePath.endsWith(SLASH_META_INF_MODULE_XML)) {
       DeploymentDescriptor deploymentDescriptor =
           DeploymentDescriptorPersistence.loadDeploymentDescriptor(file);
       ModuleDescriptor result = null;
       IFile realDescriptorFile = getRealDescriptorFile(filePath, deploymentDescriptor);
       if (realDescriptorFile != null) {
         result = loadModuleDescriptor(realDescriptorFile);
       }
       // TODO create module without sources
       if (result != null) {
         result.setDeploymentDescriptor(deploymentDescriptor);
         // TODO fix stubs
       }
       return result;
     } else {
       return DescriptorIOFacade.getInstance().fromFileType(file).readFromFile(file);
     }
   } catch (Exception t) {
     LOG.error("Fail to load module from descriptor " + file.getPath(), t);
     return null;
   }
 }
Beispiel #2
0
  private void processExcludes(
      @NotNull IFile descriptorFile, ModuleDescriptor descriptor, Set<IFile> excludes) {
    if (descriptor == null || descriptorFile.isReadOnly()) {
      return;
    }

    for (String p : descriptor.getSourcePaths()) {
      excludes.add(FileSystem.getInstance().getFileByPath(p));
    }

    IFile genPath = ProjectPathUtil.getGeneratorOutputPath(descriptorFile.getParent(), descriptor);
    if (genPath != null) {
      excludes.add(genPath);
      if (!descriptorFile.isReadOnly()) {
        FileSystem.getInstance().getFileByPath(FileGenerationUtil.getCachesPath(genPath.getPath()));
      }
    }

    IFile testsGenPath = ProjectPathUtil.getGeneratorTestsOutputPath(descriptorFile, descriptor);
    if (testsGenPath != null) {
      excludes.add(testsGenPath);
      if (!descriptorFile.isReadOnly()) {
        FileSystem.getInstance()
            .getFileByPath(FileGenerationUtil.getCachesPath(testsGenPath.getPath()));
      }
    }

    for (ModelRootDescriptor rootDescriptor : descriptor.getModelRootDescriptors()) {
      ModelRoot root = rootDescriptor.getRoot();
      if (root == null
          || root.getManager() != null && root.getManager() != LanguageID.JAVA_MANAGER) {
        continue;
      }

      excludes.add(FileSystem.getInstance().getFileByPath(root.getPath()));
    }

    IFile classesGen = ProjectPathUtil.getClassesGenFolder(descriptorFile.getParent(), false);
    if (classesGen != null) {
      excludes.add(classesGen);
    }

    // todo: specify what kind of descriptor can be input for this method
    if (descriptor instanceof LanguageDescriptor) {
      IFile generatorClassesGen =
          ProjectPathUtil.getClassesGenFolder(descriptorFile.getParent(), true);
      if (generatorClassesGen != null) {
        excludes.add(generatorClassesGen);
      }
    }

    for (String entry : descriptor.getAdditionalJavaStubPaths()) {
      excludes.add(FileSystem.getInstance().getFileByPath(entry));
    }
  }
Beispiel #3
0
 public ModuleHandle loadHandle(ModelInputStream stream) throws IOException {
   if (stream.readShort() != 0x1be0) throw new IOException("bad stream: no start marker");
   String file = stream.readString();
   ModuleDescriptor descriptor;
   int type = stream.readByte();
   if (type == 1) {
     descriptor = new LanguageDescriptor();
   } else if (type == 2) {
     descriptor = new SolutionDescriptor();
   } else if (type == 3) {
     descriptor = new DevkitDescriptor();
   } else {
     throw new IOException("broken stream: invalid descriptor type");
   }
   descriptor.load(stream);
   return new ModuleHandle(FileSystem.getInstance().getFileByPath(file), descriptor);
 }