Search in sources :

Example 1 with FormatterConfiguration

use of net.sf.eclipsecs.core.transformer.FormatterConfiguration in project eclipse-cs by checkstyle.

the class TransformFormatterRulesJob method runInWorkspace.

/**
 * {@inheritDoc}
 */
@Override
public IStatus runInWorkspace(final IProgressMonitor arg0) throws CoreException {
    // TODO this way of loading formatter profiles is very dubious, to say
    // the least, refer to FormatterConfigWriter for a better API
    final String workspace = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
    final String configLocation = workspace + "/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs";
    FormatterConfigParser parser = null;
    try {
        parser = new FormatterConfigParser(configLocation);
    } catch (final FileNotFoundException e) {
        return Status.CANCEL_STATUS;
    }
    final FormatterConfiguration rules = parser.parseRules();
    if (rules == null) {
        return Status.CANCEL_STATUS;
    }
    try {
        FormatterTransformer transformer = new FormatterTransformer(rules);
        transformer.transformRules(workspace + "/test-checkstyle.xml");
    } catch (CheckstylePluginException e) {
        Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e);
        throw new CoreException(status);
    }
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) FormatterConfiguration(net.sf.eclipsecs.core.transformer.FormatterConfiguration) FormatterConfigParser(net.sf.eclipsecs.core.transformer.FormatterConfigParser) CoreException(org.eclipse.core.runtime.CoreException) FileNotFoundException(java.io.FileNotFoundException) CheckstylePluginException(net.sf.eclipsecs.core.util.CheckstylePluginException) FormatterTransformer(net.sf.eclipsecs.core.transformer.FormatterTransformer)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 FormatterConfigParser (net.sf.eclipsecs.core.transformer.FormatterConfigParser)1 FormatterConfiguration (net.sf.eclipsecs.core.transformer.FormatterConfiguration)1 FormatterTransformer (net.sf.eclipsecs.core.transformer.FormatterTransformer)1 CheckstylePluginException (net.sf.eclipsecs.core.util.CheckstylePluginException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1