/** * Reads the {@link LineRange} object the cursor is pointing at. */ public LineRange next() { int s = read(); int d = read(); return new LineRange(s, s + d); }
/** * Returns the total number of duplicate lines. * * @return the number of duplicate lines */ public int getNumberOfLines() { return getLineRanges().iterator().next().getEnd() - getPrimaryLineNumber() + 1; }
/** * Reads the {@link LineRange} object the cursor is pointing at. */ public LineRange next() { int s = read(); int d = read(); return new LineRange(s, s + d); }
private void setAffectedLines(final BugInstance warning, final Bug bug) { Iterator<BugAnnotation> annotationIterator = warning.annotationIterator(); while (annotationIterator.hasNext()) { BugAnnotation bugAnnotation = annotationIterator.next(); if (bugAnnotation instanceof SourceLineAnnotation) { SourceLineAnnotation annotation = (SourceLineAnnotation)bugAnnotation; bug.addLineRange(new LineRange(annotation.getStartLine(), annotation.getEndLine())); } } }
private void setAffectedLines(final BugInstance warning, final Bug bug) { Iterator<BugAnnotation> annotationIterator = warning.annotationIterator(); while (annotationIterator.hasNext()) { BugAnnotation bugAnnotation = annotationIterator.next(); if (bugAnnotation instanceof SourceLineAnnotation) { SourceLineAnnotation annotation = (SourceLineAnnotation)bugAnnotation; bug.addLineRange(new LineRange(annotation.getStartLine(), annotation.getEndLine())); } } }
private void setAffectedLines(final BugInstance warning, final Bug bug) { Iterator<BugAnnotation> annotationIterator = warning.annotationIterator(); while (annotationIterator.hasNext()) { BugAnnotation bugAnnotation = annotationIterator.next(); if (bugAnnotation instanceof SourceLineAnnotation) { SourceLineAnnotation annotation = (SourceLineAnnotation)bugAnnotation; bug.addLineRange(new LineRange(annotation.getStartLine(), annotation.getEndLine())); } } }
/** * Creates a new instance of <code>AbstractAnnotation</code>. * * @param message * the message of the warning * @param start * the first line of the line range * @param end * the last line of the line range * @param category * the category of the annotation * @param type * the type of the annotation */ @edu.umd.cs.findbugs.annotations.SuppressWarnings("ST") public AbstractAnnotation(final String message, final int start, final int end, final String category, final String type) { this.message = TreeString.of(StringUtils.strip(message)); this.category = StringUtils.defaultString(category); this.type = StringUtils.defaultString(type); key = currentKey++; lineRanges = new LineRangeList(); lineRanges.add(new LineRange(start, end)); primaryLineNumber = start; contextHashCode = currentKey; }
boolean isFirstRange = true; for (LineRange range : annotation.getLineRanges()) { while (lineNumber < range.getStart()) { copyLine(output, lineIterator); lineNumber++; output.append("\">\n"); output.append("<div id=\"line"); output.append(range.getStart()); output.append("\" tooltip=\""); if (range.getStart() > 0) { outputEscaped(output, annotation.getMessage()); output.append("\" nodismiss=\"\">\n"); output.append("<code><b>\n"); if (range.getStart() <= 0) { output.append(annotation.getMessage()); if (StringUtils.isBlank(annotation.getMessage())) { while (lineNumber <= range.getEnd()) { copyLine(output, lineIterator); lineNumber++;
/** * Creates a new instance of <code>AbstractAnnotation</code>. * * @param message * the message of the warning * @param start * the first line of the line range * @param end * the last line of the line range * @param category * the category of the annotation * @param type * the type of the annotation */ @SuppressFBWarnings("ST") public AbstractAnnotation(final String message, final int start, final int end, final String category, final String type) { this.message = TreeString.of(StringUtils.strip(message)); this.category = defaultString(category); this.type = defaultString(type); key = currentKey++; lineRanges = new LineRangeList(); lineRanges.add(new LineRange(start, end)); primaryLineNumber = start; contextHashCode = currentKey; }
boolean isFirstRange = true; for (LineRange range : annotation.getLineRanges()) { while (lineNumber < range.getStart()) { copyLine(output, lineIterator); lineNumber++; output.append("\">\n"); output.append("<div tooltip=\""); if (range.getStart() > 0) { outputEscaped(output, annotation.getMessage()); output.append("\" nodismiss=\"\">\n"); output.append("<code><b>\n"); if (range.getStart() <= 0) { output.append(annotation.getMessage()); if (StringUtils.isBlank(annotation.getMessage())) { while (lineNumber <= range.getEnd()) { copyLine(output, lineIterator); lineNumber++;
/** * Verifies the created project. * * @param project the created project */ @SuppressWarnings("PMD") protected void verifyProject(final JavaProject project) { assertTrue(project.hasAnnotations()); checkSummary(project); assertTrue(MODULE_NOT_IN_PROJECT, project.containsModule(MODULE1)); assertTrue(MODULE_NOT_IN_PROJECT, project.containsModule(MODULE2)); checkFirstModule(project.getModule(MODULE1)); checkSecondModule(project.getModule(MODULE2)); for (FileAnnotation annotation : project.getModule(MODULE2).getAnnotations()) { assertEquals("Wrong primary line number.", LINE_NUMBER, annotation.getPrimaryLineNumber()); Collection<LineRange> lineRanges = annotation.getLineRanges(); assertEquals("Wrong number of ranges.", 1, lineRanges.size()); LineRange range = lineRanges.iterator().next(); assertEquals("Wrong start line number.", LINE_NUMBER, range.getStart()); assertEquals("Wrong end line number.", LINE_NUMBER, range.getEnd()); assertEquals("Wrong package prefix.", Messages.PackageDetail_header(), project.getModule(MODULE2).getPackageCategoryName()); assertSame(annotation, project.getAnnotation(annotation.getKey())); assertSame(annotation, project.getAnnotation(Long.toString(annotation.getKey()))); } }
/** * Verifies the created project. * * @param project the created project */ @SuppressWarnings("PMD") protected void verifyProject(final JavaProject project) { assertTrue(project.hasAnnotations()); checkSummary(project); assertTrue(MODULE_NOT_IN_PROJECT, project.containsModule(MODULE1)); assertTrue(MODULE_NOT_IN_PROJECT, project.containsModule(MODULE2)); checkFirstModule(project.getModule(MODULE1)); checkSecondModule(project.getModule(MODULE2)); for (FileAnnotation annotation : project.getModule(MODULE2).getAnnotations()) { assertEquals("Wrong primary line number.", LINE_NUMBER, annotation.getPrimaryLineNumber()); Collection<LineRange> lineRanges = annotation.getLineRanges(); assertEquals("Wrong number of ranges.", 1, lineRanges.size()); LineRange range = lineRanges.iterator().next(); assertEquals("Wrong start line number.", LINE_NUMBER, range.getStart()); assertEquals("Wrong end line number.", LINE_NUMBER, range.getEnd()); assertEquals("Wrong package prefix.", Messages.PackageDetail_header(), project.getModule(MODULE2).getPackageCategoryName()); assertSame(annotation, project.getAnnotation(annotation.getKey())); assertSame(annotation, project.getAnnotation(Long.toString(annotation.getKey()))); } }