Package com.puppycrawl.tools.checkstyle.api

Examples of com.puppycrawl.tools.checkstyle.api.CheckstyleException


      throws CheckstyleException {
    // TODO: improve the error handing
    final String name = aChildConf.getName();
    final Object module = mModuleFactory.createModule(name);
    if (!(module instanceof Check)) {
      throw new CheckstyleException(
          "TreeWalker is not allowed as a parent of " + name);
    }
    final Check c = (Check) module;
    c.contextualize(mChildContext);
    c.configure(aChildConf);
View Full Code Here


          if (Arrays.binarySearch(acceptableTokens, tokenId) >= 0) {
            registerCheck(token, aCheck);
          }
          // TODO: else log warning
        } catch (final IllegalArgumentException ex) {
          throw new CheckstyleException("illegal token \""
              + token + "\" in check " + aCheck, ex);
        }
      }
    } else {
      tokens = aCheck.getDefaultTokens();
View Full Code Here

        LocalizedMessage.setLocale(locale);

        if (mModuleFactory == null) {

            if (mModuleClassLoader == null) {
                throw new CheckstyleException(
                        "if no custom moduleFactory is set, "
                        + "moduleClassLoader must be specified");
            }

            final Set<String> packageNames = PackageNamesLoader.getPackageNames(
View Full Code Here

            else if (child instanceof AuditListener) {
                final AuditListener listener = (AuditListener) child;
                addListener(listener);
            }
            else {
                throw new CheckstyleException(name
                    + " is not allowed as a child in Checker");
            }
        }
        catch (final Exception ex) {
            // TODO i18n
            throw new CheckstyleException(
                    "cannot initialize module "
                    + name + " - " + ex.getMessage(), ex);
        }
    }
View Full Code Here

        InputStream is = null;
        try {
            is = aUri.toURL().openStream();
        }
        catch (final MalformedURLException e) {
            throw new CheckstyleException("syntax error in url " + aUri, e);
        }
        catch (final IOException e) {
            throw new CheckstyleException("unable to find " + aUri, e);
        }
        final InputSource source = new InputSource(is);
        return load(source, aUri);
    }
View Full Code Here

            final ImportControlLoader loader = new ImportControlLoader();
            loader.parseInputSource(aSource);
            return loader.getRoot();
        }
        catch (final ParserConfigurationException e) {
            throw new CheckstyleException("unable to parse " + aUri, e);
        }
        catch (final SAXException e) {
            throw new CheckstyleException("unable to parse " + aUri
                    + " - " + e.getMessage(), e);
        }
        catch (final IOException e) {
            throw new CheckstyleException("unable to read " + aUri, e);
        }
    }
View Full Code Here

        Enumeration<URL> packageFiles = null;
        try {
            packageFiles = aClassLoader.getResources(CHECKSTYLE_PACKAGES);
        }
        catch (IOException e) {
            throw new CheckstyleException(
                    "unable to get package file resources", e);
        }

        //create the loader outside the loop to prevent PackageObjectFactory
        //being created anew for each file
        final PackageNamesLoader namesLoader = newPackageNamesLoader();

        while ((null != packageFiles) && packageFiles.hasMoreElements()) {
            final URL aPackageFile = packageFiles.nextElement();
            InputStream stream = null;

            try {
                stream = new BufferedInputStream(aPackageFile.openStream());
                final InputSource source = new InputSource(stream);
                loadPackageNamesSource(source, "default package names",
                    namesLoader);
            }
            catch (IOException e) {
                throw new CheckstyleException(
                        "unable to open " + aPackageFile, e);
            }
            finally {
                if (stream != null) {
                    try {
                        stream.close();
                    }
                    catch (IOException e) {
                        throw new CheckstyleException(
                                "error closing stream", e);
                    }
                }
            }
        }
View Full Code Here

    {
        try {
            return new PackageNamesLoader();
        }
        catch (final ParserConfigurationException e) {
            throw new CheckstyleException(
                    "unable to create PackageNamesLoader ", e);
        }
        catch (final SAXException e) {
            throw new CheckstyleException(
                    "unable to create PackageNamesLoader - "
                    + e.getMessage(), e);
        }
    }
View Full Code Here

    {
        try {
            aNameLoader.parseInputSource(aSource);
        }
        catch (final SAXException e) {
            throw new CheckstyleException("unable to parse "
                    + aSourceName + " - " + e.getMessage(), e);
        }
        catch (final IOException e) {
            throw new CheckstyleException("unable to read " + aSourceName, e);
        }
    }
View Full Code Here

    /** {@inheritDoc} */
    public String getAttribute(String aName) throws CheckstyleException
    {
        if (!mAttributeMap.containsKey(aName)) {
            // TODO: i18n
            throw new CheckstyleException(
                    "missing key '" + aName + "' in " + getName());
        }
        return mAttributeMap.get(aName);
    }
View Full Code Here

TOP

Related Classes of com.puppycrawl.tools.checkstyle.api.CheckstyleException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.