return "com.google.collide.TestCode";
}
public void testFindReferenceInFileAfterEdit() {
// Test data.
PathUtil filePath = new PathUtil("/foo.js");
Document document = Document.createFromString(""
+ "var defvar = 5;\n"
+ "var myvar = defvar;\n");
CodeReference codeReference =
DtoClientImpls.MockCodeReferenceImpl.make()
.setReferenceStart(DtoClientImpls.FilePositionImpl.make()
.setLineNumber(1).setColumn(12))
.setReferenceEnd(DtoClientImpls.FilePositionImpl.make()
.setLineNumber(1).setColumn(17))
.setTargetFilePath(filePath.getPathString())
.setTargetStart(DtoClientImpls.FilePositionImpl.make()
.setLineNumber(0).setColumn(4))
.setTargetEnd(DtoClientImpls.FilePositionImpl.make()
.setLineNumber(0).setColumn(9))
.setReferenceType(CodeReference.Type.VAR);
JsoArray<CodeReference> codeReferences = JsoArray.from(codeReference);
CodeReferences fileReferences =
DtoClientImpls.CodeReferencesImpl.make().setReferences(codeReferences);
// Environment.
AppContext appContext = new MockAppContext();
Editor editor = Editor.create(appContext);
editor.setDocument(document);
MockCubeClient cubeClient = MockCubeClient.create();
cubeClient.setPath(filePath.getPathString());
ReferenceStore referenceStore = null;
try {
referenceStore = new ReferenceStore(cubeClient);
referenceStore.onDocumentChanged(document, null);
referenceStore.updateReferences(
new CubeData(filePath.getPathString(), null, null, null, null, fileReferences));
LineInfo line1 = document.getLineFinder().findLine(1);
// Check that there's reference at positions 12 to 17 inclusive (line 2).
assertNotNull(referenceStore.findReference(line1, 12, true));
assertNotNull(referenceStore.findReference(line1, 17, true));