lineTokens.add(new Token(CodeMirror2.HTML, TokenType.WHITESPACE, " "));
prepareAutocompleter();
Document document = helper.editor.getDocument();
AnchorManager anchorManager = document.getAnchorManager();
Line line = document.getFirstLine();
HtmlAutocompleter htmlAutocompleter = helper.autocompleter.htmlAutocompleter;
// Delete the anchor that was set by prepareAutocompleter().
JsonArray<Anchor> anchors =
AnchorManager.getAnchorsByTypeOrNull(line, HtmlAutocompleter.MODE_ANCHOR_TYPE);
assertEquals(0, anchors.size());
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 0));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 1));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 2));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 3));
Anchor anchor = anchorManager.createAnchor(HtmlAutocompleter.MODE_ANCHOR_TYPE, line,
AnchorManager.IGNORE_LINE_NUMBER, 2);
anchor.setValue("m1");
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 0));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 1));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 2));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 3));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 4));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 5));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 6));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 10));
anchor = anchorManager.createAnchor(HtmlAutocompleter.MODE_ANCHOR_TYPE, line,
AnchorManager.IGNORE_LINE_NUMBER, 1);
anchor.setValue("m0");
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 0));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 1));
assertEquals("m0", htmlAutocompleter.getModeForColumn(line, 2));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 3));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 4));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 5));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 6));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 10));
anchor = anchorManager.createAnchor(HtmlAutocompleter.MODE_ANCHOR_TYPE, line,
AnchorManager.IGNORE_LINE_NUMBER, 5);
anchor.setValue("m2");
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 0));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 1));
assertEquals("m0", htmlAutocompleter.getModeForColumn(line, 2));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 3));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 4));
assertEquals("m1", htmlAutocompleter.getModeForColumn(line, 5));
assertEquals("m2", htmlAutocompleter.getModeForColumn(line, 6));
assertEquals("m2", htmlAutocompleter.getModeForColumn(line, 10));
anchor = anchorManager.createAnchor(HtmlAutocompleter.MODE_ANCHOR_TYPE, line,
AnchorManager.IGNORE_LINE_NUMBER, 4);
anchor.setValue("m3");
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 0));
assertEquals(CodeMirror2.HTML, htmlAutocompleter.getModeForColumn(line, 1));
assertEquals("m0", htmlAutocompleter.getModeForColumn(line, 2));