c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java
branchrelease82
changeset 18425 4b288c339c55
parent 18415 35b6125ef00c
child 18426 76cdf4401581
     1.1 --- a/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java	Wed Jun 07 20:23:29 2017 +0300
     1.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java	Thu Jun 15 13:26:38 2017 +0300
     1.3 @@ -39,7 +39,6 @@
     1.4   */
     1.5  package com.sun.tools.ide.analysis.modernize.impl;
     1.6  
     1.7 -import com.sun.tools.ide.analysis.modernize.impl.ModernizeAnalyzerImpl.ResponseImpl;
     1.8  import com.sun.tools.ide.analysis.modernize.impl.YamlParser.Replacement;
     1.9  import com.sun.tools.ide.analysis.modernize.options.AnalyzerPreferences;
    1.10  import com.sun.tools.ide.analysis.modernize.options.ClangAnalyzerOptions;
    1.11 @@ -78,6 +77,7 @@
    1.12  import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
    1.13  import org.netbeans.modules.nativeexecution.api.ExecutionEnvironmentFactory;
    1.14  import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
    1.15 +import org.netbeans.spi.editor.hints.ErrorDescription;
    1.16  import org.netbeans.spi.editor.hints.Fix;
    1.17  import org.openide.filesystems.FileObject;
    1.18  import org.openide.filesystems.FileUtil;
    1.19 @@ -95,8 +95,10 @@
    1.20  public final class ModernizeErrorProvider extends CsmErrorProvider implements CodeAuditProvider, AbstractCustomizerProvider {
    1.21  
    1.22      public static final Logger LOG = Logger.getLogger("ide.analysis.tidy"); //NOI18N
    1.23 +    public static final String NAME = "Modernize"; //NOI18N
    1.24 +
    1.25      private Collection<CodeAudit> audits;
    1.26 -    public static final String NAME = "Modernize"; //NOI18N
    1.27 +    private AnalyzerResponseMerger analyzerResponseMerger;
    1.28  
    1.29      public static ModernizeErrorProvider getInstance() {
    1.30          for (CsmErrorProvider provider : Lookup.getDefault().lookupAll(CsmErrorProvider.class)) {
    1.31 @@ -187,7 +189,7 @@
    1.32  
    1.33      public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
    1.34          String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath();
    1.35 -        boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl;
    1.36 +        boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ModernizeResponse;
    1.37          if (binaryPath == null) {
    1.38              Level level = isAnalyzer ? Level.INFO : Level.FINE;
    1.39              LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N
    1.40 @@ -196,6 +198,7 @@
    1.41  
    1.42          if (isAnalyzer && isNewRun()) {
    1.43              AnalyzedFiles.getDefault().clear();
    1.44 +            analyzerResponseMerger = new AnalyzerResponseMerger((ModernizeAnalyzerImpl.ModernizeResponse) response);
    1.45          }
    1.46  
    1.47          DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath);
    1.48 @@ -215,7 +218,7 @@
    1.49              }
    1.50  
    1.51              if (!isAnalyzer) {
    1.52 -                response = new ResponseMerger(response);
    1.53 +                response = new CsmResponseMerger(response);
    1.54              }
    1.55  
    1.56              for (CsmFile startFile : tu) {
    1.57 @@ -234,9 +237,7 @@
    1.58                  response.done();
    1.59              }
    1.60  
    1.61 -        } catch (ConnectionManager.CancellationException ex) {
    1.62 -            Exceptions.printStackTrace(ex);
    1.63 -        } catch (IOException ex) {
    1.64 +        } catch (ConnectionManager.CancellationException | IOException ex) {
    1.65              Exceptions.printStackTrace(ex);
    1.66          }
    1.67      }
    1.68 @@ -251,9 +252,13 @@
    1.69          return false;
    1.70      }
    1.71  
    1.72 +    public Collection<ErrorDescription> done() {
    1.73 +        return analyzerResponseMerger.done();
    1.74 +    }
    1.75 +
    1.76      public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List<YamlParser.Diagnostics> results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
    1.77          CsmFile file = request.getFile();
    1.78 -        List<CsmFile> otherCsmFiles = new ArrayList<CsmFile>();
    1.79 +        List<CsmFile> otherCsmFiles = new ArrayList<>();
    1.80  
    1.81          for (YamlParser.Diagnostics diag : results) {
    1.82              // TODO: don't add "Configure Hint" fix multiple times for one line
    1.83 @@ -272,7 +277,7 @@
    1.84  
    1.85              if (isAnalyzer) {
    1.86                  // Add found errors for all files (can be other files from compileUnit)
    1.87 -                ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info);
    1.88 +                analyzerResponseMerger.addError(info, fo);
    1.89  
    1.90                  if (!csmFile.equals(file)) {
    1.91                      // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... )