use of org.eclipse.linuxtools.internal.cdt.libhover.LibHoverLibrary in project linuxtools by eclipse.
the class CheckDevhelp method testParse.
@Test
public void testParse() throws IOException {
ParseDevHelp.DevHelpParser p = new ParseDevHelp.DevHelpParser(// $NON-NLS-1$
"/usr/share/gtk-doc/html");
LibHoverInfo hover = p.parse(new NullProgressMonitor());
assertNotNull(hover);
Map<String, FunctionInfo> functions = hover.functions;
assertNotNull(functions);
assertFalse(functions.isEmpty());
// Now, output the LibHoverInfo for caching later
IPath location = LibhoverPlugin.getDefault().getStateLocation().append(// $NON-NLS-1$
"C");
File ldir = new File(location.toOSString());
ldir.mkdir();
// $NON-NLS-1$
location = location.append("devhelp.libhover");
try (FileOutputStream f = new FileOutputStream(location.toOSString());
ObjectOutputStream out = new ObjectOutputStream(f)) {
out.writeObject(hover);
}
IPreferenceStore ps = LibhoverPlugin.getDefault().getPreferenceStore();
ps.setValue(CACHE_EXT_LIBHOVER, true);
LibHover.getLibHoverDocs();
Collection<LibHoverLibrary> c = LibHover.getLibraries();
assertFalse(c.isEmpty());
boolean found = false;
for (LibHoverLibrary l : c) {
if (l.getName().equals("devhelp")) {
// $NON-NLS-1$
found = true;
}
}
assertTrue(found);
}
use of org.eclipse.linuxtools.internal.cdt.libhover.LibHoverLibrary in project linuxtools by eclipse.
the class LibHoverPreferencePage method regenerate.
private synchronized void regenerate() {
generateButton.setEnabled(false);
Job k = new Job(LibHoverMessages.getString(REGENERATE_MSG)) {
@Override
protected IStatus run(IProgressMonitor monitor) {
IPreferenceStore ps = DevHelpPlugin.getDefault().getPreferenceStore();
ParseDevHelp.DevHelpParser p = new ParseDevHelp.DevHelpParser(ps.getString(PreferenceConstants.DEVHELP_DIRECTORY));
LibHoverInfo hover = p.parse(monitor);
// Update the devhelp library info if it is on library list
Collection<LibHoverLibrary> libs = LibHover.getLibraries();
for (LibHoverLibrary l : libs) {
if (l.getName().equals("devhelp")) {
// $NON-NLS-1$
l.setHoverinfo(hover);
break;
}
}
try {
// Now, output the LibHoverInfo for caching later
// $NON-NLS-1$
IPath location = LibhoverPlugin.getDefault().getStateLocation().append("C");
File ldir = new File(location.toOSString());
ldir.mkdir();
// $NON-NLS-1$
location = location.append("devhelp.libhover");
try (FileOutputStream f = new FileOutputStream(location.toOSString());
ObjectOutputStream out = new ObjectOutputStream(f)) {
out.writeObject(hover);
}
monitor.done();
} catch (IOException e) {
monitor.done();
return new Status(IStatus.ERROR, DevHelpPlugin.PLUGIN_ID, e.getLocalizedMessage(), e);
}
return Status.OK_STATUS;
}
};
k.setUser(true);
k.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
Display.getDefault().syncExec(() -> {
if (generateButton != null)
generateButton.setEnabled(true);
});
}
});
k.schedule();
}
Aggregations