use of org.erlide.engine.services.search.ModelUtilService in project erlide_eclipse by erlang.
the class CreateHeaderQuickFix method run.
@Override
public void run() {
final ModelUtilService svc = ErlangEngine.getInstance().getModelUtilService();
final String name = getQuickFix().getArgs().get(0);
final IErlProject project = svc.getProject(module);
final Iterator<IPath> iterator = project.getProperties().getIncludeDirs().iterator();
final IPath inc;
if (!iterator.hasNext()) {
inc = module.getResource().getParent().getProjectRelativePath();
} else {
inc = iterator.next();
// if there are multiple include dirs, let user move file manually
}
final IProject wproject = project.getWorkspaceProject();
final IFolder folder = wproject.getFolder(inc);
final IFile header = folder.getFile(name);
try (final EmptyInputStream source = new EmptyInputStream()) {
header.create(source, true, null);
folder.refreshLocal(IResource.DEPTH_ONE, null);
final IFile fileToOpen = header;
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IDE.openEditor(page, fileToOpen);
} catch (final CoreException e) {
ErlLogger.error(e);
} catch (final IOException e) {
ErlLogger.error(e);
}
}
Aggregations