Package org.codehaus.janino

Examples of org.codehaus.janino.Compiler$SimpleWarningHandler


        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


      final Collection<CompilationProblem> problems = new ArrayList<CompilationProblem>();
     
      final StringPattern[] pattern = StringPattern.PATTERNS_NONE;

      final Compiler compiler = new Compiler(
          new ResourceFinder() {
          @Override
                    public Resource findResource( final String pSourceName ) {
            final byte[] bytes = pResourceReader.getBytes(pSourceName);
           
            if (bytes == null) {
              log.debug("failed to find source " + pSourceName);
              return null;
            }
           
            log.debug("reading " + pSourceName + " (" + bytes.length + ")");
           
            return new JciResource(pSourceName, bytes);
          }       
          },
          new ClassLoaderIClassLoader(pClassLoader),
          new ResourceFinder() {
          @Override
                    public Resource findResource( final String pResourceName ) {
            final byte[] bytes = pStore.read(pResourceName);
           
            if (bytes == null) {
              log.debug("failed to find " + pResourceName);
              return null;
            }

            log.debug("reading " + pResourceName + " (" + bytes.length + ")");
           
            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 ) {
            log.debug("removing " + pResourceName);

            pStore.remove(pResourceName);
            return true;
          }           
          },
          pSettings.getSourceEncoding(),
          false,
          pSettings.isDebug(),
                pSettings.isDebug(),
                pSettings.isDebug(),
          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++) {
            log.debug("compiling " + pSourceNames[i]);
            final byte[] source = pResourceReader.getBytes(pSourceNames[i]);
            resources[i] = new JciResource(pSourceNames[i], source);
        }
       
        try {
            compiler.compile(resources);
        } catch ( LocatedException e ) {
            problems.add(new JaninoCompilationProblem(e));
        } catch ( IOException e ) {
            // low level problems reading or writing bytes
          log.error("this error should have been cought before", e);
View Full Code Here

        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

      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

TOP

Related Classes of org.codehaus.janino.Compiler$SimpleWarningHandler

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.