Examples of Compiler


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.Compiler

*/
Compiler getCompiler(ICompilerRequestor compilerRequestor) {
  CompilerOptions compilerOptions = new CompilerOptions(this.options);
  compilerOptions.performMethodsFullRecovery = true;
  compilerOptions.performStatementsRecovery = true;
  return new Compiler(
    this.environment,
    DefaultErrorHandlingPolicies.exitAfterAllProblems(),
    compilerOptions,
    compilerRequestor,
    this.problemFactory);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.Compiler

  FileSystem environment = getLibraryAccess();
  this.compilerOptions = new CompilerOptions(this.options);
  this.compilerOptions.performMethodsFullRecovery = false;
  this.compilerOptions.performStatementsRecovery = false;
  this.batchCompiler =
    new Compiler(
      environment,
      getHandlingPolicy(),
      this.compilerOptions,
      getBatchRequestor(),
      getProblemFactory(),
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.Compiler

}
/**
* Creates and returns a compiler for this evaluator.
*/
Compiler getCompiler(ICompilerRequestor compilerRequestor) {
  Compiler compiler = super.getCompiler(compilerRequestor);
 
  // Initialize the compiler's lookup environment with the already compiled super class
  IBinaryType binaryType = this.context.getRootCodeSnippetBinary();
  if (binaryType != null) {
    compiler.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
 
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.Compiler

}
/**
* @see Evaluator
*/
Compiler getCompiler(ICompilerRequestor compilerRequestor) {
  Compiler compiler = null;
  if (!DEVELOPMENT_MODE) {
    // If we are not developping the code snippet support classes,
    // use a regular compiler and feed its lookup environment with
    // the code snippet support classes

    CompilerOptions compilerOptions = new CompilerOptions(this.options);
    compilerOptions.performMethodsFullRecovery = true;
    compilerOptions.performStatementsRecovery = true;
    compiler =
      new CodeSnippetCompiler(
        this.environment,
        DefaultErrorHandlingPolicies.exitAfterAllProblems(),
        compilerOptions,
        compilerRequestor,
        this.problemFactory,
        this.context,
        getMapper().startPosOffset,
        getMapper().startPosOffset + this.codeSnippet.length - 1);
    ((CodeSnippetParser) compiler.parser).lineSeparatorLength = this.context.lineSeparator.length();
    // Initialize the compiler's lookup environment with the already compiled super classes
    IBinaryType binary = this.context.getRootCodeSnippetBinary();
    if (binary != null) {
      compiler.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/);
    }
    VariablesInfo installedVars = this.context.installedVars;
    if (installedVars != null) {
      ClassFile[] globalClassFiles = installedVars.classFiles;
      for (int i = 0; i < globalClassFiles.length; i++) {
        ClassFileReader binaryType = null;
        try {
          binaryType = new ClassFileReader(globalClassFiles[i].getBytes(), null);
        } catch (ClassFormatException e) {
          e.printStackTrace(); // Should never happen since we compiled this type
        }
        compiler.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
      }
    }
  } else {
    // If we are developping the code snippet support classes,
    // use a wrapped environment so that if the code snippet classes are not found
    // then a default implementation is provided.

    CompilerOptions compilerOptions = new CompilerOptions(this.options);
    compilerOptions.performMethodsFullRecovery = true;
    compilerOptions.performStatementsRecovery = true;
    compiler = new Compiler(
      getWrapperEnvironment(),
      DefaultErrorHandlingPolicies.exitAfterAllProblems(),
      compilerOptions,
      compilerRequestor,
      this.problemFactory);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.Compiler

 
  // called once when the builder is initialized... can override if needed
  CompilerOptions compilerOptions = new CompilerOptions(projectOptions);
  compilerOptions.performMethodsFullRecovery = true;
  compilerOptions.performStatementsRecovery = true;
  Compiler newCompiler = new Compiler(
    nameEnvironment,
    DefaultErrorHandlingPolicies.proceedWithAllProblems(),
    compilerOptions,
    this,
    ProblemFactory.getProblemFactory(Locale.getDefault()));
View Full Code Here

Examples of org.castor.xmlctf.compiler.Compiler

        checkExpectedSources();
       
        // 2. Compile the files generated by the source generator
        verbose("--> Compiling the files in " + _outputRootFile);
        try {
            Compiler compiler = new SunJavaCompiler(_outputRootFile);
            if (_unitTest.hasJavaSourceVersion()) {
                compiler.setJavaSourceVersion(_unitTest.getJavaSourceVersion());
            }
            compiler.compileDirectory();
        } catch (CompilationException e) {
            if (!checkExceptionWasExpected(e, FailureStepType.SOURCE_COMPILATION)) {
                fail("Compiling generated source failed: " + e.getMessage());
            }
            return;
View Full Code Here

Examples of org.codehaus.janino.Compiler

        final Collection problems = new ArrayList();

        final StringPattern[] pattern = StringPattern.PATTERNS_NONE;

        final Compiler compiler = new Compiler(
                new ResourceFinder() {
                    public Resource findResource( final String pSourceName ) {
                        final byte[] bytes = pResourceReader.getBytes(pSourceName);

                        if (bytes == null) {
                            return null;
                        }

                        return new JciResource(pSourceName, bytes);
                    }
                },
                new ClassLoaderIClassLoader(pClassLoader),
                new ResourceFinder() {
                    public Resource findResource( final String pResourceName ) {
                        final byte[] bytes = pStore.read(pResourceName);

                        if (bytes == null) {
                            return null;
                        }

                        return new JciResource(pResourceName, bytes);
                    }
                },
                new ResourceCreator() {
                    public OutputStream createResource( final String pResourceName ) throws IOException {
                        return new JciOutputStream(pResourceName, pStore);
                    }

                    public boolean deleteResource( final String pResourceName ) {
                        pStore.remove(pResourceName);
                        return true;
                    }
                },
                pSettings.getSourceEncoding(),
                false,
                pSettings.isDebug()?DebuggingInformation.ALL:DebuggingInformation.NONE,
                new FilterWarningHandler(pattern, new WarningHandler() {
                        public void handleWarning( final String pHandle, final String pMessage, final Location pLocation ) {
                            final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, false);
                            if (problemHandler != null) {
                                problemHandler.handle(problem);
                            }
                            problems.add(problem);
                        }
                    })
                );

        compiler.setCompileErrorHandler(new ErrorHandler() {
            public void handleError( final String pMessage, final Location pLocation ) throws CompileException {
                final CompilationProblem problem = new JaninoCompilationProblem(pLocation.getFileName(), pLocation, pMessage, true);
                if (problemHandler != null) {
                    problemHandler.handle(problem);
                }
                problems.add(problem);
            }
        });


        final Resource[] resources = new Resource[pSourceNames.length];
        for (int i = 0; i < pSourceNames.length; i++) {
            final byte[] source = pResourceReader.getBytes(pSourceNames[i]);
            resources[i] = new JciResource(pSourceNames[i], source);
        }
        try {
            compiler.compile(resources);
        } catch ( ScanException e ) {
            problems.add(new JaninoCompilationProblem(e));
        } catch ( ParseException e ) {
            problems.add(new JaninoCompilationProblem(e));
        } catch ( IOException e ) {
View Full Code Here

Examples of org.codehaus.plexus.compiler.Compiler

        // Look up the compiler. This is done before other code than can
        // cause the mojo to return before the lookup is done possibly resulting
        // in misconfigured POMs still building.
        // ----------------------------------------------------------------------

        Compiler compiler;

        getLog().debug( "Using compiler '" + compilerId + "'." );

        try
        {
            compiler = compilerManager.getCompiler( compilerId );
        }
        catch ( NoSuchCompilerException e )
        {
            throw new MojoExecutionException( "No such compiler '" + e.getCompilerId() + "'." );
        }

        //-----------toolchains start here ----------------------------------
        //use the compilerId as identifier for toolchains as well.
        Toolchain tc = getToolchain();
        if ( tc != null )
        {
            getLog().info( "Toolchain in compiler-plugin: " + tc );
            if ( executable != null )
            {
                getLog().warn( "Toolchains are ignored, 'executable' parameter is set to " + executable );
            }
            else
            {
                fork = true;
                //TODO somehow shaky dependency between compilerId and tool executable.
                executable = tc.findTool( compilerId );
            }
        }
        // ----------------------------------------------------------------------
        //
        // ----------------------------------------------------------------------

        List<String> compileSourceRoots = removeEmptyCompileSourceRoots( getCompileSourceRoots() );

        if ( compileSourceRoots.isEmpty() )
        {
            getLog().info( "No sources to compile" );

            return;
        }

        if ( getLog().isDebugEnabled() )
        {
            getLog().debug( "Source directories: " + compileSourceRoots.toString().replace( ',', '\n' ) );
            getLog().debug( "Classpath: " + getClasspathElements().toString().replace( ',', '\n' ) );
            getLog().debug( "Output directory: " + getOutputDirectory() );
        }

        // ----------------------------------------------------------------------
        // Create the compiler configuration
        // ----------------------------------------------------------------------

        CompilerConfiguration compilerConfiguration = new CompilerConfiguration();

        compilerConfiguration.setOutputLocation( getOutputDirectory().getAbsolutePath() );

        compilerConfiguration.setClasspathEntries( getClasspathElements() );

        compilerConfiguration.setSourceLocations( compileSourceRoots );

        compilerConfiguration.setOptimize( optimize );

        compilerConfiguration.setDebug( debug );

        if ( debug && StringUtils.isNotEmpty( debuglevel ) )
        {
            String[] split = StringUtils.split( debuglevel, "," );
            for ( int i = 0; i < split.length; i++ )
            {
                if ( !( split[i].equalsIgnoreCase( "none" ) || split[i].equalsIgnoreCase( "lines" )
                    || split[i].equalsIgnoreCase( "vars" ) || split[i].equalsIgnoreCase( "source" ) ) )
                {
                    throw new IllegalArgumentException( "The specified debug level: '" + split[i] + "' is unsupported. "
                                                            + "Legal values are 'none', 'lines', 'vars', and 'source'." );
                }
            }
            compilerConfiguration.setDebugLevel( debuglevel );
        }

        compilerConfiguration.setVerbose( verbose );

        compilerConfiguration.setShowWarnings( showWarnings );

        compilerConfiguration.setShowDeprecation( showDeprecation );

        compilerConfiguration.setSourceVersion( getSource() );

        compilerConfiguration.setTargetVersion( getTarget() );

        compilerConfiguration.setProc( proc );

        compilerConfiguration.setGeneratedSourcesDirectory( getGeneratedSourcesDirectory() );

        compilerConfiguration.setAnnotationProcessors( annotationProcessors );

        compilerConfiguration.setSourceEncoding( encoding );

        Map<String, String> effectiveCompilerArguments = getCompilerArguments();

        String effectiveCompilerArgument = getCompilerArgument();

        if ( ( effectiveCompilerArguments != null ) || ( effectiveCompilerArgument != null ) )
        {
            LinkedHashMap<String, String> cplrArgsCopy = new LinkedHashMap<String, String>();
            if ( effectiveCompilerArguments != null )
            {
                for ( Map.Entry<String, String> me : effectiveCompilerArguments.entrySet() )
                {
                    String key = me.getKey();
                    String value = me.getValue();
                    if ( !key.startsWith( "-" ) )
                    {
                        key = "-" + key;
                    }

                    if ( key.startsWith( "-A" ) && StringUtils.isNotEmpty( value ) )
                    {
                        cplrArgsCopy.put( key + "=" + value, null );
                    }
                    else
                    {
                        cplrArgsCopy.put( key, value );
                    }
                }
            }
            if ( !StringUtils.isEmpty( effectiveCompilerArgument ) )
            {
                cplrArgsCopy.put( effectiveCompilerArgument, null );
            }
            compilerConfiguration.setCustomCompilerArguments( cplrArgsCopy );
        }

        compilerConfiguration.setFork( fork );

        if ( fork )
        {
            if ( !StringUtils.isEmpty( meminitial ) )
            {
                String value = getMemoryValue( meminitial );

                if ( value != null )
                {
                    compilerConfiguration.setMeminitial( value );
                }
                else
                {
                    getLog().info( "Invalid value for meminitial '" + meminitial + "'. Ignoring this option." );
                }
            }

            if ( !StringUtils.isEmpty( maxmem ) )
            {
                String value = getMemoryValue( maxmem );

                if ( value != null )
                {
                    compilerConfiguration.setMaxmem( value );
                }
                else
                {
                    getLog().info( "Invalid value for maxmem '" + maxmem + "'. Ignoring this option." );
                }
            }
        }

        compilerConfiguration.setExecutable( executable );

        compilerConfiguration.setWorkingDirectory( basedir );

        compilerConfiguration.setCompilerVersion( compilerVersion );

        compilerConfiguration.setBuildDirectory( buildDirectory );

        compilerConfiguration.setOutputFileName( outputFileName );

        if ( CompilerConfiguration.CompilerReuseStrategy.AlwaysNew.getStrategy().equals( this.compilerReuseStrategy ) )
        {
            compilerConfiguration.setCompilerReuseStrategy( CompilerConfiguration.CompilerReuseStrategy.AlwaysNew );
        }
        else if ( CompilerConfiguration.CompilerReuseStrategy.ReuseSame.getStrategy().equals(
            this.compilerReuseStrategy ) )
        {
            if ( getRequestThreadCount() > 1 )
            {
                if ( !skipMultiThreadWarning )
                {
                    StringBuilder sb = new StringBuilder(
                        "You are in a multi-thread build and compilerReuseStrategy is set to reuseSame. This can cause issues in some environments (os/jdk)! Consider using reuseCreated strategy." );
                    sb.append( System.getProperty( "line.separator" ) );
                    sb.append(
                        "If your env is fine with reuseSame, you can skip this warning with the configuration field skipMultiThreadWarning or -Dmaven.compiler.skipMultiThreadWarning=true" );
                    getLog().warn( sb.toString() );
                }
            }
            compilerConfiguration.setCompilerReuseStrategy( CompilerConfiguration.CompilerReuseStrategy.ReuseSame );
        }
        else
        {

            compilerConfiguration.setCompilerReuseStrategy( CompilerConfiguration.CompilerReuseStrategy.ReuseCreated );
        }

        getLog().debug( "CompilerReuseStrategy: " + compilerConfiguration.getCompilerReuseStrategy().getStrategy() );

        // TODO: have an option to always compile (without need to clean)
        Set<File> staleSources;

        boolean canUpdateTarget;

        try
        {
            staleSources =
                computeStaleSources( compilerConfiguration, compiler, getSourceInclusionScanner( staleMillis ) );

            canUpdateTarget = compiler.canUpdateTarget( compilerConfiguration );

            if ( compiler.getCompilerOutputStyle().equals( CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES )
                && !canUpdateTarget )
            {
                getLog().info( "RESCANNING!" );
                // TODO: This second scan for source files is sub-optimal
                String inputFileEnding = compiler.getInputFileEnding( compilerConfiguration );

                Set<File> sources = computeStaleSources( compilerConfiguration, compiler,
                                                         getSourceInclusionScanner( inputFileEnding ) );

                compilerConfiguration.setSourceFiles( sources );
            }
            else
            {
                compilerConfiguration.setSourceFiles( staleSources );
            }
        }
        catch ( CompilerException e )
        {
            throw new MojoExecutionException( "Error while computing stale sources.", e );
        }

        if ( staleSources.isEmpty() )
        {
            getLog().info( "Nothing to compile - all classes are up to date" );

            return;
        }

        // ----------------------------------------------------------------------
        // Dump configuration
        // ----------------------------------------------------------------------

        if ( getLog().isDebugEnabled() )
        {
            getLog().debug( "Classpath:" );

            for ( String s : getClasspathElements() )
            {
                getLog().debug( " " + s );
            }

            getLog().debug( "Source roots:" );

            for ( String root : getCompileSourceRoots() )
            {
                getLog().debug( " " + root );
            }

            try
            {
                if ( fork )
                {
                    if ( compilerConfiguration.getExecutable() != null )
                    {
                        getLog().debug( "Excutable: " );
                        getLog().debug( " " + compilerConfiguration.getExecutable() );
                    }
                }

                String[] cl = compiler.createCommandLine( compilerConfiguration );
                if ( cl != null && cl.length > 0 )
                {
                    StringBuilder sb = new StringBuilder();
                    sb.append( cl[0] );
                    for ( int i = 1; i < cl.length; i++ )
                    {
                        sb.append( " " );
                        sb.append( cl[i] );
                    }
                    getLog().debug( "Command line options:" );
                    getLog().debug( sb );
                }
            }
            catch ( CompilerException ce )
            {
                getLog().debug( ce );
            }
        }

        // ----------------------------------------------------------------------
        // Compile!
        // ----------------------------------------------------------------------

        if ( StringUtils.isEmpty( compilerConfiguration.getSourceEncoding() ) )
        {
            getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
                               + ", i.e. build is platform dependent!" );
        }

        List<CompilerError> messages;

        try
        {
            messages = compiler.compile( compilerConfiguration );
        }
        catch ( Exception e )
        {
            // TODO: don't catch Exception
            throw new MojoExecutionException( "Fatal error compiling", e );
View Full Code Here

Examples of org.crsh.lang.spi.Compiler

    activeCompilers.put("script", ScriptCompiler.getInstance());

    //
    for (Language lang : context.getPlugins(Language.class)) {
      if (lang.isActive()) {
        Compiler compiler = lang.getCompiler();
        if (compiler != null) {
          for (String ext : compiler.getExtensions()) {
            activeCompilers.put(ext, compiler);
          }
        }
      }
    }
View Full Code Here

Examples of org.dynjs.runtime.Compiler

    private final JSProgram script;
    private final Debugger debugger;

    public DynJSProgram(DynJSRuntime runtime, Debugger debugger, String source, String fileName) throws Throwable {
        Compiler compiler = runtime.newCompiler();
        compiler.withSource(source);
        compiler.withFileName(fileName);
        this.script = compiler.compile();
        this.debugger = debugger;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.