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;
}
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();
}
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);
}
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();
}
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;
}
Aggregations