package net.sf.alchim.spoon.contrib.maven;

import org.apache.maven.plugin.logging.Log;

import spoon.processing.FileGenerator;
import spoon.processing.Processor;
import spoon.processing.Severity;
import spoon.reflect.declaration.CtElement;
import spoon.support.StandardEnvironment;

@SuppressWarnings("serial")
class MavenEnvironment extends StandardEnvironment {
    private final Log logger_;

    public MavenEnvironment(Log log) {
        logger_ = log;
    }

    @Override()
    public void debugMessage(String msg) {
        logger_.debug(msg);
    }

    @SuppressWarnings("unchecked")
    @Override()
    public void report(Processor processor, Severity severity, CtElement element, String message) {
        String msg = processor.getClass().getSimpleName() + ">>" + element.getPosition().getFile().getAbsolutePath() + "@[" + element.getPosition().getLine() + "," + element.getPosition().getColumn() + "]:" + message;
        if (Severity.ERROR.equals(severity)) {
            logger_.error(msg);
        } else if (Severity.WARNING.equals(severity)) {
            logger_.warn(msg);
        } else {
            logger_.info(msg);
        }
    }

    @Override
    public FileGenerator<? extends CtElement> getDefaultFileGenerator() {
        return super.getDefaultFileGenerator();
    }

}

@@ -106,28 +106,27 @@
 cessing.
-FileGenerato
+ProblemFixe
 r;%0Aimpor
@@ -387,16 +387,76 @@
 logger_;
+%0A    private int warningCount_;%0A    private int errorCount_;
 %0A%0A    pu
@@ -608,24 +608,660 @@
 sg);%0A    %7D%0A%0A
+    @Override%0A    public void setDebug(boolean v) %7B%0A        if (logger_.isDebugEnabled() != v) %7B%0A            logger_.warn(%22can't change logger level to debug = %22 + v);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public boolean isDebug() %7B%0A        return logger_.isDebugEnabled();%0A    %7D%0A%0A    @Override%0A    public void setVerbose(boolean v) %7B%0A        if (logger_.isInfoEnabled() != v) %7B%0A            logger_.warn(%22can't change logger level to info = %22 + v);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Returns true if Spoon is in verbose mode.%0A     */%0A    @Override%0A    public boolean isVerbose() %7B%0A        return logger_.isInfoEnabled();%0A    %7D%0A%0A    @Override%0A
     @Suppres
@@ -1283,32 +1283,16 @@
 ecked%22)%0A
-    @Override()%0A
     publ
@@ -1402,59 +1402,119 @@
 ing 
-msg = processor.getClass().getSimpleName() + %22%3E%3E%22 +
+where = %22%22;%0A        if (element != null) %7B%0A            where = String.format(%22%25s@%5B%25d,%25d%5D:%22,%0A                   
  ele
@@ -1563,17 +1563,29 @@
 th()
- + %22@%5B%22 +
+,%0A                   
  ele
@@ -1616,16 +1616,29 @@
 ne()
- + %22,%22 +
+,%0A                   
  ele
@@ -1671,25 +1671,237 @@
 mn()
- + %22%5D:%22 + message
+%0A                    );%0A        %7D%0A        String msg = String.format(%22%25s %3E%3E %25s %25s%22,%0A                (processor == null) ? %22%22 : processor.getClass().getSimpleName(),%0A                where,%0A                message%0A                )
 ;%0A  
@@ -1937,32 +1937,59 @@
 ls(severity)) %7B%0A
+            errorCount_++;%0A
             logg
@@ -2052,32 +2052,61 @@
 ls(severity)) %7B%0A
+            warningCount_++;%0A
             logg
@@ -2177,32 +2177,909 @@
        %7D%0A    %7D%0A%0A
+    @SuppressWarnings(%22unchecked%22)%0A    @Override%0A    public void report(Processor processor, Severity severity, String message) %7B%0A        report(processor, severity, null, message);%0A    %7D%0A%0A    @Override%0A    @SuppressWarnings(%22unchecked%22)%0A    public void report(Processor processor, Severity severity, CtElement element, String message, ProblemFixer... fix) %7B%0A        // Fix not (yet) used in command-line mode%0A        report(processor, severity, element, message);%0A    %7D%0A%0A    /**%0A     * This method should be called to report the end of the processing.%0A     */%0A    @Override%0A    public void reportEnd() %7B%0A        if (isVerbose()) %7B%0A            logger_.info(String.format(%22end of processing: %25d warning(s), %25d error(s)%22, warningCount_, errorCount_));%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void reportProgressMessage(String message) %7B%0A        logger_.info(message);%0A    %7D%0A/*%0A
     @Override%0A  
@@ -3204,11 +3204,13 @@
 ;%0A    %7D%0A
+*/
 %0A%7D%0A

use maven logger for every report (include new from spoon-core-1.2)