Search in sources :

Example 1 with SpecFile

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

the class TaskGenerateAdoc method getPackagesCountTotal.

int getPackagesCountTotal() {
    File docRootDir = configAdocPage.getConfig().getDocRootDir();
    String packagesDir = docRootDir + SEP + DIR_ADOC_GEN + SEP + DIR_PACKAGES;
    List<String> packageFileNames = FileSystem.getAdocFileNames(packagesDir);
    Collections.sort(packageFileNames);
    int changedPackageFiles = 0;
    int updated = 0;
    if (specChangeSet != null)
        for (SpecFile specFile : specChangeSet) {
            if (specFile instanceof SpecIndexFile) {
                // This is an approximation since e.g. the overview files are also SpecIndexFiles
                // Error: 0..+2
                changedPackageFiles++;
                if (packageFileNames.contains(specFile.getFile().getName()))
                    updated++;
            }
        }
    return packageFileNames.size() + changedPackageFiles - updated;
}
Also used : SpecModuleFile(org.eclipse.n4js.jsdoc2spec.adoc.SpecModuleFile) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecIndexFile(org.eclipse.n4js.jsdoc2spec.adoc.SpecIndexFile) SpecIndexFile(org.eclipse.n4js.jsdoc2spec.adoc.SpecIndexFile) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 2 with SpecFile

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

the class TaskWriteFiles method writeAdocFiles.

private void writeAdocFiles(IProgressMonitor monitor) throws IOException, InterruptedException {
    Set<SpecFile> specChangeSet = taskGenAdoc.getSpecChangeSet();
    monitor.beginTask("Write adoc files", specChangeSet.size() + 1);
    for (SpecFile specChangeFile : specChangeSet) {
        File file = specChangeFile.getFile();
        String newContent = specChangeFile.getNewContent();
        if (file.exists()) {
            file.delete();
        }
        File parent = file.getParentFile();
        if (!parent.exists() && !parent.mkdirs()) {
            throw new IllegalStateException("Couldn't create dir: " + parent);
        }
        file.createNewFile();
        Files.write(newContent, file, Charsets.UTF_8);
        monitor.worked(1);
        CheckCanceled.checkUserCanceled(monitor);
    }
    monitor.worked(1);
    monitor.done();
}
Also used : SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile) File(java.io.File) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 3 with SpecFile

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

the class SpecComparePage method initcomboBox.

private void initcomboBox() {
    String[] items = new String[specChanges.size()];
    int i = 0;
    for (SpecFile specChange : specChanges) {
        String fileName = specChange.getFile().getName();
        String module = specChange.getPackageDisplayName();
        String itemName = fileName;
        if (module != null && module.length() > 0)
            itemName += " (" + module + ")";
        items[i++] = itemName;
    }
    comboCurrentFile.setItems(items);
}
Also used : SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 4 with SpecFile

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

the class SpecComparePage method setCompareViewerInput.

private void setCompareViewerInput(int dataIndex) {
    if (fViewer.getControl().isDisposed())
        return;
    if (specChanges.isEmpty())
        return;
    SpecFile specChange = specChanges.get(dataIndex);
    fViewer.setInput(new DiffNode(new OriginalElementFromFile(specChange.getFile()), new TargetElementFromString(specChange.getNewContent())));
    fViewer.refresh();
}
Also used : DiffNode(org.eclipse.compare.structuremergeviewer.DiffNode) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

Example 5 with SpecFile

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

the class IndicesCreator method getIndexEntries.

/**
 * This method creates a list of {@link IndexEntry}s from a list of {@link SpecModuleFile}s. Since the given
 * collection <code>specFiles</code> also contains other {@link SpecFile}s, it is filtered first. It retrieves start
 * and end offsets and also a {@link SourceEntry}.
 */
private static ArrayList<IndexEntry> getIndexEntries(Collection<SpecFile> specFiles) {
    ArrayList<IndexEntry> entries = new ArrayList<>();
    for (SpecFile specFile : specFiles) {
        if (specFile instanceof SpecModuleFile) {
            SpecModuleFile smf = (SpecModuleFile) specFile;
            for (SpecIdentifiableElementSection specIE : smf.getSpecSections()) {
                SourceEntry pc = specIE.getSourceEntry();
                int offsetStart = specFile.getOffsetStart(specIE);
                int offsetEnd = specFile.getOffsetEnd(specIE);
                if (pc == null) {
                    pc = specIE.getSourceEntry();
                }
                IndexEntry ie = new IndexEntry(pc, offsetStart, offsetEnd);
                entries.add(ie);
            }
        }
    }
    return entries;
}
Also used : ArrayList(java.util.ArrayList) SpecFile(org.eclipse.n4js.jsdoc2spec.SpecFile)

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