@Override public int getEndLine(Object impl) { SourceSection section = (SourceSection) impl; return section.getEndLine(); }
@Override public int getEndLine(Object impl) { SourceSection section = (SourceSection) impl; return section.getEndLine(); }
private static boolean intersectsLines(SourceSection section1, SourceSection section2) { int x1 = section1.getStartLine(); int x2 = section1.getEndLine(); int y1 = section2.getStartLine(); int y2 = section2.getEndLine(); return x2 >= y1 && y2 >= x1; }
private static String getShortDescription(SourceSection sourceSection) { StringBuilder b = new StringBuilder(); b.append(sourceSection.getSource().getName()); b.append(":"); if (sourceSection.getStartLine() == sourceSection.getEndLine()) { b.append(sourceSection.getStartLine()); } else { b.append(sourceSection.getStartLine()).append("-").append(sourceSection.getEndLine()); } return b.toString(); }
private static String formatIndices(SourceSection sourceSection, boolean needsColumnSpecifier) { StringBuilder b = new StringBuilder(); boolean singleLine = sourceSection.getStartLine() == sourceSection.getEndLine(); if (singleLine) { b.append(sourceSection.getStartLine()); } else { b.append(sourceSection.getStartLine()).append("-").append(sourceSection.getEndLine()); } if (needsColumnSpecifier) { b.append(":"); if (sourceSection.getCharLength() <= 1) { b.append(sourceSection.getCharIndex()); } else { b.append(sourceSection.getCharIndex()).append("-").append(sourceSection.getCharIndex() + sourceSection.getCharLength() - 1); } } return b.toString(); }
static String formatIndices(SourceSection sourceSection, boolean needsColumnSpecifier) { StringBuilder b = new StringBuilder(); boolean singleLine = sourceSection.getStartLine() == sourceSection.getEndLine(); if (singleLine) { b.append(sourceSection.getStartLine()); } else { b.append(sourceSection.getStartLine()).append("-").append(sourceSection.getEndLine()); } if (needsColumnSpecifier) { b.append(":"); if (sourceSection.getCharLength() <= 1) { b.append(sourceSection.getCharIndex()); } else { b.append(sourceSection.getCharIndex()).append("-").append(sourceSection.getCharIndex() + sourceSection.getCharLength() - 1); } } return b.toString(); }
static String formatIndices(SourceSection sourceSection, boolean needsColumnSpecifier) { StringBuilder b = new StringBuilder(); boolean singleLine = sourceSection.getStartLine() == sourceSection.getEndLine(); if (singleLine) { b.append(sourceSection.getStartLine()); } else { b.append(sourceSection.getStartLine()).append("-").append(sourceSection.getEndLine()); } if (needsColumnSpecifier) { b.append(":"); if (sourceSection.getCharLength() <= 1) { b.append(sourceSection.getCharIndex()); } else { b.append(sourceSection.getCharIndex()).append("-").append(sourceSection.getCharIndex() + sourceSection.getCharLength() - 1); } } return b.toString(); }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return ColumnIn.isColumnIn(rootSection, ranges); } return true; }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return ColumnIn.isColumnIn(rootSection, ranges); } return true; }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return isColumnIn(rootSection, ranges); } return true; }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return isColumnIn(rootSection, ranges); } return true; }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return ColumnIn.isColumnIn(rootSection, ranges); } return true; }
@Override boolean isRootIncluded(Set<Class<?>> providedTags, SourceSection rootSection, RootNode rootNode, int rootNodeBits) { if (RootNodeBits.isNoSourceSection(rootNodeBits)) { return false; } if (RootNodeBits.isSourceSectionsHierachical(rootNodeBits) && rootSection != null && rootSection.getStartLine() == rootSection.getEndLine()) { return ColumnIn.isColumnIn(rootSection, ranges); } return true; }
@Override boolean isIncluded(Set<Class<?>> providedTags, Node instrumentedNode, SourceSection sourceSection) { if (sourceSection == null || !sourceSection.isAvailable()) { return false; } int otherStart = sourceSection.getStartLine(); int otherEnd; if (sourceSection.getSource() == null) { otherEnd = otherStart; } else { otherEnd = sourceSection.getEndLine(); } for (IndexRange indexRange : ranges) { if (indexRange.contains(otherEnd, otherEnd)) { return true; } } return false; }
static boolean isLineIn(SourceSection sourceSection, IndexRange[] ranges) { if (sourceSection == null || !sourceSection.isAvailable()) { return false; } int otherStart = sourceSection.getStartLine(); int otherEnd; if (sourceSection.getSource() == null) { otherEnd = otherStart; } else { otherEnd = sourceSection.getEndLine(); } for (IndexRange indexRange : ranges) { if (indexRange.contains(otherStart, otherEnd)) { return true; } } return false; }
static boolean isLineIn(SourceSection sourceSection, IndexRange[] ranges) { if (sourceSection == null || !sourceSection.isAvailable()) { return false; } int otherStart = sourceSection.getStartLine(); int otherEnd; if (sourceSection.getSource() == null) { otherEnd = otherStart; } else { otherEnd = sourceSection.getEndLine(); } for (IndexRange indexRange : ranges) { if (indexRange.contains(otherStart, otherEnd)) { return true; } } return false; }
@Override boolean isIncluded(Set<Class<?>> providedTags, Node instrumentedNode, SourceSection sourceSection) { if (sourceSection == null || !sourceSection.isAvailable()) { return false; } int otherStart = sourceSection.getStartLine(); int otherEnd; if (sourceSection.getSource() == null) { otherEnd = otherStart; } else { otherEnd = sourceSection.getEndLine(); } for (IndexRange indexRange : ranges) { if (indexRange.contains(otherEnd, otherEnd)) { return true; } } return false; }
private boolean matchSectionLine(InstrumentableNode node, SourceSection sourceSection) { if (line > 0) { int l; switch (anchor) { case BEFORE: l = sourceSection.getStartLine(); break; case AFTER: l = sourceSection.getEndLine(); break; default: throw new IllegalArgumentException(anchor.name()); } if (line == l && isTaggedWith(node, elementTags)) { if (exactLineMatch == null || (anchor == SuspendAnchor.BEFORE) && sourceSection.getCharIndex() < exactLineMatch.getCharIndex() || (anchor == SuspendAnchor.AFTER) && sourceSection.getCharEndIndex() > exactLineMatch.getCharEndIndex()) { exactLineMatch = sourceSection; } } if (exactLineMatch != null) { return true; } } return false; }
InstrumentableNode getContainsNode() { if (containsNode == null) { return null; } if (line > 0) { if (anchor == SuspendAnchor.BEFORE && line == containsMatch.getStartLine() || anchor == SuspendAnchor.AFTER && line == containsMatch.getEndLine()) { return (InstrumentableNode) containsNode.getOuter(containsMatch.getCharLength()); } } else { if (anchor == SuspendAnchor.BEFORE && offset == containsMatch.getCharIndex() || anchor == SuspendAnchor.AFTER && offset == containsMatch.getCharEndIndex() - 1) { return (InstrumentableNode) containsNode.getOuter(containsMatch.getCharLength()); } } return (InstrumentableNode) containsNode.getInner(containsMatch.getCharLength()); }
static JSONObject sourceSectionToJSON(SourceSection sourceSection) { JSONObject sourceSectionJson = new JSONObject(); if (sourceSection != null) { Source source = sourceSection.getSource(); if (source != null) { if (source.getLanguage() != null) { sourceSectionJson.put("language", source.getLanguage().toString()); } String path = source.getPath(); if (path != null) { sourceSectionJson.put("path", path); } } sourceSectionJson.put("source_name", sourceSection.getSource().getName()); sourceSectionJson.put("start_line", sourceSection.getStartLine()); sourceSectionJson.put("end_line", sourceSection.getEndLine()); sourceSectionJson.put("start_column", sourceSection.getStartColumn()); sourceSectionJson.put("end_column", sourceSection.getEndColumn()); } return sourceSectionJson; }