@Test public void testHandleChangeWatchedFiles_deleted() throws IOException { File newFolder1 = root.newFolder(); File catFile = addFileToFolder(newFolder1, "Cat.groovy", "class Cat {\n" + "}\n"); GroovyWorkspaceCompiler compiler = createGroovyWorkspaceCompiler(); // Compile assertEquals(NO_ERRORS, compiler.compile(ImmutableSet.of())); // Assert the original file is in the compilation unit assertSingleSourceFileUri(catFile, compiler.get().iterator()); // Delete the file assertThat(catFile.delete()).isTrue(); // Call handleChangeWatchedFile with a change saying this file has been deleted outside this language server compiler.handleChangeWatchedFiles(Lists.newArrayList( new FileEvent( root.getRoot().toPath().relativize(catFile.toPath()).toString(), FileChangeType.Changed))); // Re-compile assertEquals(NO_ERRORS, compiler.compile(ImmutableSet.of())); // Assert the compiler has no source units assertThat(compiler.get().iterator().hasNext()).isFalse(); }
assertSingleSourceFileUri(catFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator()); assertSingleSourceFileUri(catFile, compiler.get().iterator());
assertSingleSourceFileUri(catFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator()); assertSingleSourceFileUri(catFile, compiler.get().iterator());
@Test public void testHandleChangeWatchedFiles_created() throws IOException { File newFolder1 = root.newFolder(); GroovyWorkspaceCompiler compiler = createGroovyWorkspaceCompiler(); // Compile assertEquals(NO_ERRORS, compiler.compile(ImmutableSet.of())); // Assert the compiler has no source units assertThat(compiler.get().iterator().hasNext()).isFalse(); File catFile = addFileToFolder(newFolder1, "Cat.groovy", "class Cat {\n" + "}\n"); // Call handleChangeWatchedFile with a change saying this file has been changed outside this language server compiler.handleChangeWatchedFiles(Lists.newArrayList( new FileEvent( root.getRoot().toPath().relativize(catFile.toPath()).toString(), FileChangeType.Created))); // Re-compile assertEquals(NO_ERRORS, compiler.compile(ImmutableSet.of())); // Assert the compilation unit now contains cat file assertSingleSourceFileUri(catFile, compiler.get().iterator()); }
assertSingleSourceFileUri(catFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator());
assertSingleSourceFileUri(catFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator()); assertSingleSourceFileUri(catChangedFile, compiler.get().iterator());