### Question:
JavadocBlockParserUtil { public static <T extends IrDocElement> T setLocation(T elem, JavadocToken start, JavadocToken stop) { int s = start.getStartPosition(); int e = stop.getStartPosition() + stop.getText().length(); IrLocation location = new IrLocation(s, e - s); elem.setLocation(location); return elem; } private  JavadocBlockParserUtil(); static T setLocation(T elem, JavadocToken start, JavadocToken stop); static T setLocation(T elem, IrLocation start, IrLocation stop); static IrDocText fetchText(JavadocScanner scanner, boolean trimHead, boolean trimTail); static JavadocBlockInfo fetchBlockInfo(JavadocScanner scanner); static int countWhileTagName(JavadocScanner scanner, int start); static IrDocSimpleName fetchSimpleName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocName fetchName(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchBasicType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocBasicType fetchPrimitiveType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocNamedType fetchNamedType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocType fetchType(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocField fetchField(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocMethod fetchMethod(JavadocScanner scanner, Set<JavadocTokenKind> follow); static IrDocFragment fetchLinkTarget(JavadocScanner scanner, Set<JavadocTokenKind> follow); static String buildString(List<? extends JavadocToken> tokens); static final Set<JavadocTokenKind> S_WHITE; }### Answer:
@Test public void testSetLocationToken() { { IrDocElement elem = new IrDocText("text"); JavadocToken start = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 10); JavadocToken stop = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 20); JavadocBlockParserUtil.setLocation(elem, start, stop); assertEquals(10, elem.getLocation().getStartPosition()); assertEquals(12, elem.getLocation().getLength()); } { IrDocElement elem = new IrDocText("text"); JavadocToken start = new JavadocToken(JavadocTokenKind.IDENTIFIER, "id", 10); JavadocBlockParserUtil.setLocation(elem, start, start); assertEquals(10, elem.getLocation().getStartPosition()); assertEquals(2, elem.getLocation().getLength()); } }
@Test public void testSetLocationLocation() { { IrDocElement elem = new IrDocText("text"); IrLocation start = new IrLocation(10, 2); IrLocation stop = new IrLocation(20, 2); JavadocBlockParserUtil.setLocation(elem, start, stop); assertEquals(10, elem.getLocation().getStartPosition()); assertEquals(12, elem.getLocation().getLength()); } { IrDocElement elem = new IrDocText("text"); IrLocation start = new IrLocation(10, 2); JavadocBlockParserUtil.setLocation(elem, start, start); assertEquals(10, elem.getLocation().getStartPosition()); assertEquals(2, elem.getLocation().getLength()); } { IrDocElement elem = new IrDocText("text"); IrLocation fragment = new IrLocation(10, 2); JavadocBlockParserUtil.setLocation(elem, null, fragment); assertNull(elem.getLocation()); } { IrDocElement elem = new IrDocText("text"); IrLocation fragment = new IrLocation(10, 2); JavadocBlockParserUtil.setLocation(elem, fragment, null); assertNull(elem.getLocation()); } }