Search in sources :

Example 1 with SubMonitorMsg

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

the class TaskGenerateAdoc method performTasks.

private void performTasks(IProgressMonitor monitor) throws IOException, InterruptedException {
    jsDoc2SpecProcessor.resetIssues();
    File rootDir = configAdoc.getDocRootDir();
    FileSystem.ensureFileStructure(rootDir);
    int workload = 0;
    if (specInfos.isEmpty())
        workload += 2;
    if (specChangeSet == null)
        workload += 2;
    SubMonitor completeProgress = SubMonitor.convert(monitor, workload);
    SubMonitorMsg cmplProgAcceptor = new SubMonitorMsg(completeProgress, processAdocPage::displayMessage, processAdocPage::displayMessageRed, CheckCanceled::checkUserCanceled);
    if (specInfos.isEmpty()) {
        SubMonitorMsg subMonitor = cmplProgAcceptor.newChild(2);
        computeTypes(subMonitor);
        subMonitor.done();
    }
    if (specChangeSet == null) {
        SubMonitorMsg subMonitor = cmplProgAcceptor.newChild(2);
        computeChangeSet(subMonitor);
        subMonitor.done();
    }
    cmplProgAcceptor.subTask("Finished.");
    if (specChangeSet.isEmpty())
        processAdocPage.displayMessage("No Changes found.");
    completeProgress.done();
}
Also used : CheckCanceled(org.eclipse.n4js.jsdoc2spec.CheckCanceled) SubMonitor(org.eclipse.core.runtime.SubMonitor) SubMonitorMsg(org.eclipse.n4js.jsdoc2spec.SubMonitorMsg) SpecModuleFile(org.eclipse.n4js.jsdoc2spec.adoc.SpecModuleFile) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecIndexFile(org.eclipse.n4js.jsdoc2spec.adoc.SpecIndexFile)

Example 2 with SubMonitorMsg

use of org.eclipse.n4js.jsdoc2spec.SubMonitorMsg 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 3 with SubMonitorMsg

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

the class TaskGenerateAdoc method computeChangeSet.

/**
 * Side effect: sets {@link #specChangeSet}
 */
private void computeChangeSet(SubMonitorMsg completeProgress) throws IOException, InterruptedException {
    specChangeSet = new TreeSet<>();
    completeProgress.subTask("Reading existing documentation ...");
    SubMonitorMsg readSpecProgress = completeProgress.newChild(1);
    jsDoc2SpecProcessor.setRootDir(configAdoc.getDocRootDir());
    CheckCanceled.checkUserCanceled(readSpecProgress);
    readSpecProgress.done();
    completeProgress.subTask("Computing updates ...");
    SubMonitorMsg compUpdtsProgress = completeProgress.newChild(1);
    Collection<SpecFile> changes = jsDoc2SpecProcessor.computeUpdates(specInfos, compUpdtsProgress);
    CheckCanceled.checkUserCanceled(compUpdtsProgress);
    compUpdtsProgress.done();
    specChangeSet.addAll(changes);
}
Also used : SubMonitorMsg(org.eclipse.n4js.jsdoc2spec.SubMonitorMsg) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Aggregations

SpecFile (org.eclipse.n4js.jsdoc2spec.SpecFile)3 SubMonitorMsg (org.eclipse.n4js.jsdoc2spec.SubMonitorMsg)3 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 CheckCanceled (org.eclipse.n4js.jsdoc2spec.CheckCanceled)1 SpecElementRef (org.eclipse.n4js.jsdoc2spec.SpecElementRef)1 SpecInfo (org.eclipse.n4js.jsdoc2spec.SpecInfo)1 SpecIndexFile (org.eclipse.n4js.jsdoc2spec.adoc.SpecIndexFile)1 SpecModuleFile (org.eclipse.n4js.jsdoc2spec.adoc.SpecModuleFile)1