Search in sources :

Example 11 with DidChangeWatchedFilesParams

use of org.eclipse.lsp4j.DidChangeWatchedFilesParams in project xtext-core by eclipse.

the class ServerTest method testIncrementalDeletion.

@Test
public void testIncrementalDeletion() {
    String model = "type Test {\n" + "    NonExisting foo\n" + "}\n";
    String path = writeFile("MyType1.testlang", model);
    initialize();
    assertEquals("Couldn't resolve reference to TypeDeclaration 'NonExisting'.", getFirstDiagnostic().getMessage());
    deleteFile("MyType1.testlang");
    languageServer.getWorkspaceService().didChangeWatchedFiles(new DidChangeWatchedFilesParams(Lists.newArrayList(new FileEvent(path, FileChangeType.Deleted))));
    Assert.assertTrue(Iterables.getFirst(getDiagnostics().values(), null).isEmpty());
}
Also used : FileEvent(org.eclipse.lsp4j.FileEvent) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams) Test(org.junit.Test)

Example 12 with DidChangeWatchedFilesParams

use of org.eclipse.lsp4j.DidChangeWatchedFilesParams in project xtext-core by eclipse.

the class IndexOnlyProjectTest method testIncrementalBuildNoValidation.

/**
 * Shows that the resource is not validated during incremental build
 */
@Test
public void testIncrementalBuildNoValidation() {
    writeFile("MyType1.testlang", "type Test { NonExisting foo }");
    initialize();
    Assert.assertTrue(Joiner.on(",").join(getDiagnostics().entrySet()), getDiagnostics().isEmpty());
    String path = writeFile("MyType2.testlang", "type NonExisting {}");
    languageServer.getWorkspaceService().didChangeWatchedFiles(new DidChangeWatchedFilesParams(Lists.newArrayList(new FileEvent(path, FileChangeType.Created))));
    Assert.assertTrue(Joiner.on(",").join(getDiagnostics().entrySet()), getDiagnostics().isEmpty());
}
Also used : FileEvent(org.eclipse.lsp4j.FileEvent) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams) Test(org.junit.Test)

Example 13 with DidChangeWatchedFilesParams

use of org.eclipse.lsp4j.DidChangeWatchedFilesParams in project sts4 by spring-projects.

the class LanguageServerHarness method changeFile.

public synchronized void changeFile(String uri) {
    FileEvent fileEvent = new FileEvent(uri, FileChangeType.Changed);
    getServer().getWorkspaceService().didChangeWatchedFiles(new DidChangeWatchedFilesParams(Arrays.asList(fileEvent)));
}
Also used : FileEvent(org.eclipse.lsp4j.FileEvent) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams)

Example 14 with DidChangeWatchedFilesParams

use of org.eclipse.lsp4j.DidChangeWatchedFilesParams in project eclipse.jdt.ls by eclipse.

the class WorkspaceEventHandlerTest method testChangeWorkingCopy.

@Test
public void testChangeWorkingCopy() throws Exception {
    importProjects("eclipse/hello");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("hello");
    // IJavaProject javaProject = JavaCore.create(project);
    IFile file = project.getFile("src/org/sample/Foo.java");
    ICompilationUnit unit = (ICompilationUnit) JavaCore.create(file);
    String source = unit.getSource();
    openDocument(unit, source, 1);
    File projectFile = project.getRawLocation().toFile();
    File classFile = new File(projectFile, "bin/org/sample/Foo.class");
    long lastModified = classFile.lastModified();
    assertTrue(lastModified > 0);
    source = source.replace("world", "world2");
    File javaFile = new File(projectFile, "src/org/sample/Foo.java");
    FileUtils.writeStringToFile(javaFile, source);
    String uri = JDTUtils.toURI(unit);
    DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams(Arrays.asList(new FileEvent(uri, FileChangeType.Changed)));
    new WorkspaceEventsHandler(projectsManager, javaClient, lifeCycleHandler).didChangeWatchedFiles(params);
    waitForBackgroundJobs();
    assertTrue(classFile.lastModified() > lastModified);
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) FileEvent(org.eclipse.lsp4j.FileEvent) IFile(org.eclipse.core.resources.IFile) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IProject(org.eclipse.core.resources.IProject) DidChangeWatchedFilesParams(org.eclipse.lsp4j.DidChangeWatchedFilesParams) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Aggregations

DidChangeWatchedFilesParams (org.eclipse.lsp4j.DidChangeWatchedFilesParams)14 FileEvent (org.eclipse.lsp4j.FileEvent)13 Test (org.junit.Test)9 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)4 File (java.io.File)3 IProject (org.eclipse.core.resources.IProject)3 IFile (org.eclipse.core.resources.IFile)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 IJavaProject (org.eclipse.jdt.core.IJavaProject)2 List (java.util.List)1 IFolder (org.eclipse.core.resources.IFolder)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1 ClientPreferences (org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 Diagnostic (org.eclipse.lsp4j.Diagnostic)1 FileSystemWatcher (org.eclipse.lsp4j.FileSystemWatcher)1 PublishDiagnosticsParams (org.eclipse.lsp4j.PublishDiagnosticsParams)1