@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 SignatureHashBuilder append(String s) { if (digest != null) try { digest.update(s.getBytes("UTF8")); } catch (UnsupportedEncodingException e) { LOG.error("Error encoding String", e); } if (builder != null) builder.append(s); return this; }
protected boolean appendSubsection( StringBuilder builder, Iterable<XImportDeclaration> subSection, boolean needsNewline) { if (!isEmpty(subSection)) { if (needsNewline) builder.append(lineSeparator); for (XImportDeclaration declaration : isSort() ? sort(subSection) : subSection) { appendImport(builder, declaration); } return true; } return needsNewline; }
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(); }
public String hash() { try { if (digest != null) { byte[] digestBytes = digest.digest(); return new BigInteger(digestBytes).toString(16); } else { return builder.toString(); } } catch (Exception e) { LOG.error("Error hashing JvmDeclaredType signature", e); return ""; } }
protected void appendImport(StringBuilder builder, XImportDeclaration newImportDeclaration) { builder.append("import "); if (newImportDeclaration.isStatic()) { builder.append("static "); if (newImportDeclaration.isExtension()) { builder.append("extension "); } } String qualifiedTypeName = newImportDeclaration.getImportedNamespace(); if (newImportDeclaration.getImportedType() != null) { qualifiedTypeName = serializeType(newImportDeclaration.getImportedType()); } String escapedTypeName = nameValueConverter.toString(qualifiedTypeName); builder.append(escapedTypeName); if (newImportDeclaration.isStatic()) { builder.append("."); if (newImportDeclaration.isWildcard()) { builder.append("*"); } else { builder.append(newImportDeclaration.getMemberName()); } } builder.append(lineSeparator); }