c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/c.s.tools.ide.analysis.modernize/test/unit/src/ide/analysis/modernize/ResponseImpl.java Wed Jun 07 20:23:29 2017 +0300
1.3 @@ -0,0 +1,46 @@
1.4 +/*
1.5 + * To change this license header, choose License Headers in Project Properties.
1.6 + * To change this template file, choose Tools | Templates
1.7 + * and open the template in the editor.
1.8 + */
1.9 +package ide.analysis.modernize;
1.10 +
1.11 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeErrorInfo;
1.12 +import com.sun.tools.ide.analysis.modernize.impl.ModernizeFix;
1.13 +import com.sun.tools.ide.analysis.modernize.impl.YamlParser;
1.14 +import java.util.List;
1.15 +import junit.framework.TestCase;
1.16 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorInfo;
1.17 +import org.netbeans.modules.cnd.api.model.syntaxerr.CsmErrorProvider;
1.18 +import org.openide.util.Exceptions;
1.19 +
1.20 +/**
1.21 + *
1.22 + * @author Ilia Gromov
1.23 + */
1.24 +class ResponseImpl implements CsmErrorProvider.Response {
1.25 +
1.26 + private final List<ModernizeFix> fixes;
1.27 +
1.28 + public ResponseImpl(List<ModernizeFix> fixes) {
1.29 + this.fixes = fixes;
1.30 + }
1.31 +
1.32 + @Override
1.33 + public void addError(CsmErrorInfo info) {
1.34 + try {
1.35 + TestCase.assertTrue(info instanceof ModernizeErrorInfo);
1.36 + final List<YamlParser.Replacement> replacements = ((ModernizeErrorInfo) info).getDiagnostics().getReplacements();
1.37 + final String id = ((ModernizeErrorInfo) info).getId();
1.38 + ModernizeFix fix = new ModernizeFix(replacements, id);
1.39 + fixes.add(fix);
1.40 + } catch (Exception ex) {
1.41 + Exceptions.printStackTrace(ex);
1.42 + }
1.43 + }
1.44 +
1.45 + @Override
1.46 + public void done() {
1.47 + }
1.48 +
1.49 +}