c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java
1.1 --- a/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.2 +++ b/c.s.tools.ide.analysis.modernize/src/com/sun/tools/ide/analysis/modernize/impl/ModernizeErrorProvider.java Thu Jun 15 14:17:04 2017 +0300
1.3 @@ -39,6 +39,7 @@
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 @@ -77,7 +78,6 @@
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,11 +95,9 @@
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 + private Collection<CodeAudit> audits;
1.24 public static final String NAME = "Modernize"; //NOI18N
1.25
1.26 - private Collection<CodeAudit> audits;
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 if (NAME.equals(provider.getName()) && provider instanceof ModernizeErrorProvider) {
1.32 @@ -189,7 +187,7 @@
1.33
1.34 public void analyze(ExecutionEnvironment execEnv, Item item, Lookup.Provider project, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
1.35 String binaryPath = ClangAnalyzerOptions.getClangAnalyzerPath();
1.36 - boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ModernizeResponse;
1.37 + boolean isAnalyzer = response instanceof ModernizeAnalyzerImpl.ResponseImpl;
1.38 if (binaryPath == null) {
1.39 Level level = isAnalyzer ? Level.INFO : Level.FINE;
1.40 LOG.log(level, "clang-tidy needs to be installed as a plugin"); //NOI18N
1.41 @@ -198,7 +196,6 @@
1.42
1.43 if (isAnalyzer && isNewRun()) {
1.44 AnalyzedFiles.getDefault().clear();
1.45 - analyzerResponseMerger = new AnalyzerResponseMerger((ModernizeAnalyzerImpl.ModernizeResponse) response);
1.46 }
1.47
1.48 DiagnosticsTool diagnosticsTool = new DiagnosticsTool(execEnv, item, (MakeProject) project, binaryPath);
1.49 @@ -218,7 +215,7 @@
1.50 }
1.51
1.52 if (!isAnalyzer) {
1.53 - response = new CsmResponseMerger(response);
1.54 + response = new ResponseMerger(response);
1.55 }
1.56
1.57 for (CsmFile startFile : tu) {
1.58 @@ -237,7 +234,9 @@
1.59 response.done();
1.60 }
1.61
1.62 - } catch (ConnectionManager.CancellationException | IOException ex) {
1.63 + } catch (ConnectionManager.CancellationException ex) {
1.64 + Exceptions.printStackTrace(ex);
1.65 + } catch (IOException ex) {
1.66 Exceptions.printStackTrace(ex);
1.67 }
1.68 }
1.69 @@ -252,13 +251,9 @@
1.70 return false;
1.71 }
1.72
1.73 - public Collection<ErrorDescription> done() {
1.74 - return analyzerResponseMerger.done();
1.75 - }
1.76 -
1.77 public void postProcess(boolean isAnalyzer, CsmFile startFile, Lookup.Provider project, List<YamlParser.Diagnostics> results, CsmErrorProvider.Request request, CsmErrorProvider.Response response) {
1.78 CsmFile file = request.getFile();
1.79 - List<CsmFile> otherCsmFiles = new ArrayList<>();
1.80 + List<CsmFile> otherCsmFiles = new ArrayList<CsmFile>();
1.81
1.82 for (YamlParser.Diagnostics diag : results) {
1.83 // TODO: don't add "Configure Hint" fix multiple times for one line
1.84 @@ -277,7 +272,7 @@
1.85
1.86 if (isAnalyzer) {
1.87 // Add found errors for all files (can be other files from compileUnit)
1.88 - analyzerResponseMerger.addError(info, fo);
1.89 + ((ResponseImpl) response).addError(AnalyzerResponse.AnalyzerSeverity.DetectedError, null, fo, info);
1.90
1.91 if (!csmFile.equals(file)) {
1.92 // May be not header (e.g BBB.cc: AAA.cc -> (includes) BBB.cc -> ... )