|
4 | 4 | import com.github.gumtreediff.tree.Tree; |
5 | 5 | import gr.uom.java.xmi.UMLAnnotation; |
6 | 6 | import gr.uom.java.xmi.UMLModel; |
| 7 | +import org.codetracker.BlockTrackerGumTreeImpl.CodeElementRange; |
7 | 8 | import org.codetracker.element.Method; |
8 | 9 | import org.eclipse.jgit.api.Git; |
9 | 10 | import org.eclipse.jgit.api.errors.GitAPIException; |
@@ -178,10 +179,31 @@ public static LineReader getLineReader(String fileContent) throws IOException { |
178 | 179 | } |
179 | 180 |
|
180 | 181 | public static int startLine(Tree tree, LineReader lr){ |
181 | | - return lr.positionFor(tree.getPos())[0]; |
| 182 | + return startLine(tree.getPos(), lr); |
| 183 | + } |
| 184 | + |
| 185 | + public static int startLine(int startPosition, LineReader lr){ |
| 186 | + return lr.positionFor(startPosition)[0]; |
182 | 187 | } |
183 | 188 |
|
184 | 189 | public static int endLine(Tree tree, LineReader lr){ |
185 | | - return lr.positionFor(tree.getEndPos())[0]; |
| 190 | + return endLine(tree.getEndPos(), lr); |
| 191 | + } |
| 192 | + |
| 193 | + public static int endLine(int endPosition, LineReader lr){ |
| 194 | + return lr.positionFor(endPosition)[0]; |
| 195 | + } |
| 196 | + |
| 197 | + public static boolean actionOverlapsElement(CodeElementRange actionRange, CodeElementRange codeElementRange) { |
| 198 | + return actionOverlapsElement(actionRange, codeElementRange, false); |
| 199 | + } |
| 200 | + |
| 201 | + public static boolean actionOverlapsElement(CodeElementRange actionRange, CodeElementRange codeElementRange, boolean line) { |
| 202 | + if (line){ |
| 203 | + return actionRange.startLine <= codeElementRange.endLine |
| 204 | + && actionRange.endLine >= codeElementRange.startLine; |
| 205 | + } |
| 206 | + return actionRange.startPosition <= codeElementRange.endPosition |
| 207 | + && actionRange.endPosition >= codeElementRange.startPosition; |
186 | 208 | } |
187 | 209 | } |
0 commit comments