Search in sources :

Example 6 with SpecFile

use of org.eclipse.n4js.jsdoc2spec.SpecFile in project n4js by eclipse.

the class JSDoc2ADocSpecProcessor method createNewEntries.

/**
 * This method iterates through the entries of {@code typesByName} and creates {@link SpecFile}s from them. The
 * entries of {@code typeByName} contain e.g. requirements, or N4JS types like classes.
 */
private Collection<SpecFile> createNewEntries(Collection<SpecInfo> specInfos, SubMonitorMsg monitor) throws InterruptedException {
    TreeMap<String, SpecFile> specChangeSet = new TreeMap<>();
    Map<String, SpecSection> specsByKey = new HashMap<>();
    SubMonitorMsg sub = monitor.convert(specInfos.size());
    for (SpecInfo specInfo : specInfos) {
        SpecElementRef specElementRef = specInfo.specElementRef;
        String specKey = KeyUtils.getSpecKey(repoPathHolder, specInfo);
        if (specsByKey.containsKey(specKey))
            throw new RuntimeException("Unexpected!");
        // create spec regions for every requirement and source element
        SpecSection specSection = null;
        if (specElementRef.requirementID != null) {
            specSection = new SpecRequirementSection(specInfo, rootDir, repoPathHolder);
            specSection.generateADocText(adocFactory, specsByKey);
            specsByKey.put(specSection.getSpecKey(), specSection);
            SpecRequirementFile srf = new SpecRequirementFile((SpecRequirementSection) specSection);
            specChangeSet.put(specSection.getSpecModuleKey(), srf);
        }
        if (specElementRef.identifiableElement != null) {
            specSection = new SpecIdentifiableElementSection(specInfo, rootDir, repoPathHolder);
            SpecIdentifiableElementSection sies = (SpecIdentifiableElementSection) specSection;
            insertIntoSpecModuleFile(specChangeSet, specsByKey, sies);
            addMembers(sies.specInfo, specsByKey, specChangeSet);
        }
        sub.worked(1);
        checkUserCanceled(sub);
    }
    Set<SpecFile> changeEntries = new HashSet<>();
    changeEntries.addAll(specChangeSet.values());
    return changeEntries;
}
Also used : SpecInfo(org.eclipse.n4js.jsdoc2spec.SpecInfo) HashMap(java.util.HashMap) SubMonitorMsg(org.eclipse.n4js.jsdoc2spec.SubMonitorMsg) TreeMap(java.util.TreeMap) SpecElementRef(org.eclipse.n4js.jsdoc2spec.SpecElementRef) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) HashSet(java.util.HashSet)

Example 7 with SpecFile

use of org.eclipse.n4js.jsdoc2spec.SpecFile in project n4js by eclipse.

the class WebContentFileWriter method getSpecFiles.

public List<SpecFile> getSpecFiles(File rootDir) {
    File adocGenDir = new File(rootDir.getAbsolutePath() + SEP + DIR_ADOC_GEN);
    File packageDir = new File(adocGenDir.getAbsolutePath() + SEP + DIR_PACKAGES);
    List<SpecFile> specFiles = new ArrayList<>();
    generateAllPackagesFile(adocGenDir, specFiles);
    generateAllModulesFile(adocGenDir, specFiles);
    for (PackageEntry pe : allPackages.values()) {
        generatePackageModulesFile(packageDir, pe, specFiles);
    }
    return specFiles;
}
Also used : ArrayList(java.util.ArrayList) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 8 with SpecFile

use of org.eclipse.n4js.jsdoc2spec.SpecFile in project n4js by eclipse.

the class WebContentFileWriter method generateAllModulesFile.

private void generateAllModulesFile(File rootDir, List<SpecFile> specFiles) {
    String fileName = "allModules.adoc";
    String absFileName = rootDir + SEP + fileName;
    File indexFile = new File(absFileName);
    String indexContent = allModulesStrb.toString();
    SpecFile scf = new SpecListingFile(indexFile, indexContent, "All Modules Overview");
    specFiles.add(scf);
}
Also used : SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 9 with SpecFile

use of org.eclipse.n4js.jsdoc2spec.SpecFile in project n4js by eclipse.

the class WebContentFileWriter method generatePackageModulesFile.

private void generatePackageModulesFile(File rootDir, PackageEntry pe, List<SpecFile> specFiles) {
    String fileName = pe.name + ".adoc";
    String absFileName = rootDir + SEP + fileName;
    File indexFile = new File(absFileName);
    String indexContent = pe.modulesStrb.toString();
    SpecFile scf = new SpecListingFile(indexFile, indexContent, "Modules Overview");
    specFiles.add(scf);
}
Also used : SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 10 with SpecFile

use of org.eclipse.n4js.jsdoc2spec.SpecFile in project n4js by eclipse.

the class JSDoc2AdocFullTest method getExpectedFileNames.

private Collection<String> getExpectedFileNames(String expectationFilesRoot, Collection<SpecFile> specFiles) {
    if (specFiles == null)
        return Collections.emptyList();
    File expFilesRoot = new File(expectationFilesRoot);
    String[] expFileNames = expFilesRoot.list();
    if (expFileNames == null)
        return Collections.emptyList();
    Set<String> expFiles = new HashSet<>(Arrays.asList(expFileNames));
    for (SpecFile specFile : specFiles) {
        String fileName = specFile.getFile().getName();
        if (expFiles.contains(fileName)) {
            expFiles.add(fileName);
        } else {
            fileName = getFolderIncludingFileName(specFile);
            if (expFiles.contains(fileName)) {
                expFiles.add(fileName);
            }
        }
    }
    return expFiles;
}
Also used : SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) HashSet(java.util.HashSet)

Aggregations

SpecFile (org.eclipse.n4js.jsdoc2spec.SpecFile)18 File (java.io.File)10 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)2 SubMonitorMsg (org.eclipse.n4js.jsdoc2spec.SubMonitorMsg)2 SpecIndexFile (org.eclipse.n4js.jsdoc2spec.adoc.SpecIndexFile)2 SpecModuleFile (org.eclipse.n4js.jsdoc2spec.adoc.SpecModuleFile)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 DiffNode (org.eclipse.compare.structuremergeviewer.DiffNode)1 URI (org.eclipse.emf.common.util.URI)1 FileBasedWorkspace (org.eclipse.n4js.internal.FileBasedWorkspace)1 N4JSModel (org.eclipse.n4js.internal.N4JSModel)1 N4JSRuntimeCore (org.eclipse.n4js.internal.N4JSRuntimeCore)1 SpecElementRef (org.eclipse.n4js.jsdoc2spec.SpecElementRef)1 SpecInfo (org.eclipse.n4js.jsdoc2spec.SpecInfo)1 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)1