Package com.puppycrawl.tools.checkstyle.api

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


        catch ( CheckstyleException e )
        {
            // Try to find the attribute in a parent, if there are any
            if ( parentConfigurations != null && !parentConfigurations.isEmpty() )
            {
                Configuration parentConfiguration = parentConfigurations.get( parentConfigurations.size() - 1 );
                List<Configuration> newParentConfigurations = new ArrayList<Configuration>( parentConfigurations );
                // Remove the last parent
                newParentConfigurations.remove( parentConfiguration );
                ret = getConfigAttribute( parentConfiguration, newParentConfigurations, attributeName, defaultValue );
            }
View Full Code Here


        {
            // Log the parent configuration path
            StringBuffer parentPath = new StringBuffer();
            for ( Iterator<Configuration> iterator = parentConfigurations.iterator(); iterator.hasNext(); )
            {
                Configuration parentConfiguration = iterator.next();
                parentPath.append( parentConfiguration.getName() );
                if ( iterator.hasNext() )
                {
                    parentPath.append( " --> " );
                }
            }
            if ( parentPath.length() > 0 )
            {
                getLog().debug( "Parent Configuration Path: " + parentPath.toString() );
            }
        }

        Configuration configChildren[] = configuration.getChildren();
        for ( int cci = 0; cci < configChildren.length; cci++ )
        {
            String ruleName = configChildren[cci].getName();

            if ( "TreeWalker".equals( ruleName ) )
View Full Code Here

        if ( filterSet != null )
        {
            checker.addFilter( filterSet );
        }
        Configuration configuration = getConfiguration( request );
        checker.configure( configuration );

        AuditListener listener = request.getListener();

        if ( listener != null )
View Full Code Here

            // so we have to fix it
            ClassLoader checkstyleClassLoader = PackageNamesLoader.class.getClassLoader();
            Thread.currentThread().setContextClassLoader( checkstyleClassLoader );
            String configFile = getConfigFile( request );
            Properties overridingProperties = getOverridingProperties( request );
            Configuration config = ConfigurationLoader
                .loadConfiguration( configFile, new PropertiesExpander( overridingProperties ) );
            String effectiveEncoding = StringUtils.isNotEmpty( request.getEncoding() ) ? request.getEncoding() : System
                .getProperty( "file.encoding", "UTF-8" );
            if ( StringUtils.isEmpty( request.getEncoding() ) )
            {
                request.getLog().warn(
                                       "File encoding has not been set, using platform encoding " + effectiveEncoding
                                           + ", i.e. build is platform dependent!" );
            }

            if ( "Checker".equals( config.getName() )
                    || "com.puppycrawl.tools.checkstyle.Checker".equals( config.getName() ) )
            {
                if ( config instanceof DefaultConfiguration )
                {
                    // MCHECKSTYLE-173 Only add the "charset" attribute if it has not been set
                    try
                    {
                        if ( ( (DefaultConfiguration) config ).getAttribute( "charset" ) == null )
                        {
                            ( (DefaultConfiguration) config ).addAttribute( "charset", effectiveEncoding );
                        }
                    }
                    catch ( CheckstyleException ex )
                    {
                        // Checkstyle 5.4+ throws an exception when trying to access an attribute that doesn't exist
                        ( (DefaultConfiguration) config ).addAttribute( "charset", effectiveEncoding );
                    }
                }
                else
                {
                    request.getLog().warn( "Failed to configure file encoding on module " + config );
                }
            }
            Configuration[] modules = config.getChildren();
            for ( int i = 0; i < modules.length; i++ )
            {
                Configuration module = modules[i];
                if ( "TreeWalker".equals( module.getName() )
                    || "com.puppycrawl.tools.checkstyle.TreeWalker".equals( module.getName() ) )
                {
                    if ( module instanceof DefaultConfiguration )
                    {
                        //MCHECKSTYLE-132 DefaultConfiguration addAttribute has changed in checkstyle 5.3
                        try
View Full Code Here

                               String aQName)
            throws SAXException
        {
            if (aQName.equals(MODULE)) {

                final Configuration recentModule =
                    mConfigStack.pop();

                // remove modules with severity ignore if these modules should
                // be omitted
                SeverityLevel level = null;
                try {
                    final String severity = recentModule.getAttribute(SEVERITY);
                    level = SeverityLevel.getInstance(severity);
                }
                catch (final CheckstyleException e) {
                    //severity not set -> ignore
                    ;
View Full Code Here

        if (!line.hasOption("c")) {
            System.out.println("Must specify a config XML file.");
            usage();
        }

        final Configuration config = loadConfig(line, props);

        // setup the output stream
        OutputStream out = null;
        boolean closeOut = false;
        if (line.hasOption("o")) {
View Full Code Here

    }

    /** @param aFileName the cache file */
    public void setCacheFile(String aFileName)
    {
        final Configuration configuration = getConfiguration();
        mCache = new PropertyCacheFile(configuration, aFileName);
    }
View Full Code Here

    private Checker createChecker()
    {
        Checker c = null;
        try {
            final Properties props = createOverridingProperties();
            final Configuration config =
                ConfigurationLoader.loadConfiguration(
                    mConfigLocation,
                    new PropertiesExpander(props),
                    mOmitIgnoredModules);
View Full Code Here

        catch ( CheckstyleException e )
        {
            // Try to find the attribute in a parent, if there are any
            if ( parentConfigurations != null && !parentConfigurations.isEmpty() )
            {
                Configuration parentConfiguration = parentConfigurations.get( parentConfigurations.size() - 1 );
                List<Configuration> newParentConfigurations = new ArrayList<Configuration>( parentConfigurations );
                // Remove the last parent
                newParentConfigurations.remove( parentConfiguration );
                ret = getConfigAttribute( parentConfiguration, newParentConfigurations, attributeName, defaultValue );
            }
View Full Code Here

        {
            // Log the parent configuration path
            StringBuilder parentPath = new StringBuilder();
            for ( Iterator<Configuration> iterator = parentConfigurations.iterator(); iterator.hasNext(); )
            {
                Configuration parentConfiguration = iterator.next();
                parentPath.append( parentConfiguration.getName() );
                if ( iterator.hasNext() )
                {
                    parentPath.append( " --> " );
                }
            }
            if ( parentPath.length() > 0 )
            {
                getLog().debug( "Parent Configuration Path: " + parentPath.toString() );
            }
        }

        Configuration configChildren[] = configuration.getChildren();
        for ( Configuration aConfigChildren : configChildren )
        {
            String ruleName = aConfigChildren.getName();

            if ( treeWalkerNames.contains( ruleName ) )
View Full Code Here

TOP

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

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.