Example #1
0
 @Override
 public String toString() {
   StringBuilder builder = new StringBuilder();
   for (TestEvent each : testEvents) {
     builder.append(each.toString() + each.getErrorClassName() + each.getMessage());
   }
   return builder.toString();
 }
 protected void addSectionToAppend(IAcceptor<ReplaceRegion> acceptor) {
   StringBuilder importDeclarationsToAppend = getImportDeclarationsToAppend();
   if (importDeclarationsToAppend.length() == 0) return;
   importRegion = regionUtil.addLeadingWhitespace(importRegion, resource);
   importRegion = regionUtil.addTrailingSingleWhitespace(importRegion, lineSeparator, resource);
   int insertOffset = importRegion.getOffset() + importRegion.getLength();
   if (insertOffset != 0 && originalImportDeclarations.isEmpty())
     importDeclarationsToAppend.insert(0, lineSeparator);
   importDeclarationsToAppend.append(lineSeparator);
   int insertLength = -importRegion.getLength();
   insertLength += regionUtil.addTrailingWhitespace(importRegion, resource).getLength();
   ReplaceRegion appendDeclarations =
       new ReplaceRegion(
           new TextRegion(insertOffset, insertLength), importDeclarationsToAppend.toString());
   acceptor.accept(appendDeclarations);
 }
 protected String serializeImports(List<XImportDeclaration> allDeclarations) {
   StringBuilder builder = new StringBuilder();
   if (needsPreceedingBlankLine()) builder.append(lineSeparator).append(lineSeparator);
   boolean needNewline =
       appendSubsection(
           builder,
           filter(
               allDeclarations,
               new Predicate<XImportDeclaration>() {
                 @Override
                 public boolean apply(XImportDeclaration input) {
                   return !input.isStatic();
                 }
               }),
           false);
   needNewline =
       appendSubsection(
           builder,
           filter(
               allDeclarations,
               new Predicate<XImportDeclaration>() {
                 @Override
                 public boolean apply(XImportDeclaration input) {
                   return input.isStatic() && !input.isExtension();
                 }
               }),
           needNewline);
   appendSubsection(
       builder,
       filter(
           allDeclarations,
           new Predicate<XImportDeclaration>() {
             @Override
             public boolean apply(XImportDeclaration input) {
               return input.isStatic() && input.isExtension();
             }
           }),
       needNewline);
   if (!isEmpty(allDeclarations)) builder.append(lineSeparator);
   return builder.toString();
 }