JavaSourceUtil { static public SourcePosition findSourcePositionInComment(String line) { if (line == null) { return null; } line = line.trim(); if (!line.startsWith(" return null; } int pos = line.indexOf(" @ ["); if (pos < 0) { return null; } int end = line.indexOf("]", pos); if (end < 0) { return null; } String sourceRef = line.substring(pos+4, end); String[] sourceRefs = sourceRef.split(":"); if (sourceRefs.length != 2) { return null; } try { int lineNumber = Integer.valueOf(sourceRefs[0]); int columnNumber = Integer.valueOf(sourceRefs[1]); return new SourcePosition(lineNumber, columnNumber, -1); } catch (NumberFormatException e) { return null; } }  static SourcePosition findSourcePosition(File javaFile, int lineNumber, int columnNumber); static SourcePosition findSourcePositionInComment(String line);  }
@Test public void findSourcePositionInComment() { SourcePosition pos; pos = JavaSourceUtil.findSourcePositionInComment(" Assert.assertEquals(4, pos.getLineNumber()); Assert.assertEquals(6, pos.getPosInLine()); }