Esempio n. 1
0
 public void test_toUI_LinkedCorrectionProposal() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChange = new SourceChange("My linked change", source);
   sourceChange.addEdit(new Edit(10, 1, "a"));
   sourceChange.addEdit(new Edit(20, 1, "a"));
   sourceChange.addEdit(new Edit(30, 3, "b"));
   // create SourceCorrectionProposal
   SourceCorrectionProposal proposal =
       new SourceCorrectionProposal(sourceChange, CorrectionKind.QA_ADD_TYPE_ANNOTATION);
   {
     List<SourceRange> ranges = ImmutableList.of(new SourceRange(10, 1), new SourceRange(20, 1));
     Map<String, List<SourceRange>> linkedPositons = ImmutableMap.of("a", ranges);
     proposal.setLinkedPositions(linkedPositons);
   }
   {
     List<LinkedPositionProposal> proposals =
         ImmutableList.of(
             new LinkedPositionProposal(CorrectionImage.IMG_CORRECTION_CHANGE, "proposalA"));
     Map<String, List<LinkedPositionProposal>> linkedProposals = ImmutableMap.of("a", proposals);
     proposal.setLinkedPositionProposals(linkedProposals);
   }
   //
   LinkedCorrectionProposal uiProposal = ServiceUtils.toUI(proposal);
   CompilationUnitChange ltkChange = (CompilationUnitChange) uiProposal.getChange();
   assertEquals("My linked change", ltkChange.getName());
 }
Esempio n. 2
0
 public void test_toUI_LinkedCorrectionProposal_noFile() throws Exception {
   Source source = new FileBasedSource(new File("no-such-file.dart"));
   SourceChange sourceChange = new SourceChange("My change", source);
   SourceCorrectionProposal proposal =
       new SourceCorrectionProposal(sourceChange, CorrectionKind.QA_ADD_TYPE_ANNOTATION);
   LinkedCorrectionProposal uiProposal = ServiceUtils.toUI(proposal);
   assertNull(uiProposal);
 }
Esempio n. 3
0
 public void test_toUI_ChangeCorrectionProposal() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChange = new SourceChange("My change", source);
   sourceChange.addEdit(new Edit(10, 1, "a"));
   sourceChange.addEdit(new Edit(20, 1, "a"));
   sourceChange.addEdit(new Edit(30, 3, "b"));
   // create ChangeCorrectionProposal
   CorrectionProposal proposal =
       new ChangeCorrectionProposal(sourceChange, CorrectionKind.QA_ADD_TYPE_ANNOTATION);
   //
   com.google.dart.tools.ui.internal.text.correction.proposals.ChangeCorrectionProposal
       uiProposal =
           (com.google.dart.tools.ui.internal.text.correction.proposals.ChangeCorrectionProposal)
               ServiceUtils.toUI(proposal);
   ReflectionUtils.invokeMethod(uiProposal, "getChange()");
   CompilationUnitChange ltkChange = (CompilationUnitChange) uiProposal.getChange();
   assertEquals("My change", ltkChange.getName());
 }