void didChangeWatchedFiles(DidChangeWatchedFilesParams param){ List<FileEvent> changes = param.getChanges(); for (FileEvent fileEvent : changes) { CHANGE_TYPE changeType = toChangeType(fileEvent.getType()); if(changeType==CHANGE_TYPE.DELETED){ cleanUpDiagnostics(fileEvent.getUri()); } ICompilationUnit unit = JDTUtils.resolveCompilationUnit(fileEvent.getUri()); if (unit != null && changeType == CHANGE_TYPE.CREATED && !unit.exists()) { final ICompilationUnit[] units = new ICompilationUnit[1]; units[0] = unit; try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { @Override public void run(IProgressMonitor monitor) throws CoreException { units[0] = createCompilationUnit(units[0]); } }, new NullProgressMonitor()); } catch (CoreException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } unit = units[0]; } if (unit != null && unit.isWorkingCopy()) { continue; } if(changeType == CHANGE_TYPE.DELETED || changeType == CHANGE_TYPE.CHANGED){ SharedASTProvider.getInstance().invalidate(unit); } pm.fileChanged(fileEvent.getUri(), changeType); } }
@Test public void testOpenedDocumentShadowsPersistedFile() { StringConcatenation _builder = new StringConcatenation(); _builder.append("type Test {"); _builder.newLine(); _builder.append(" "); _builder.append("NonExisting foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); final String firstFile = this.writeFile("MyType1.testlang", _builder); this.initialize(); this.assertEquals("Couldn\'t resolve reference to TypeDeclaration \'NonExisting\'.", IterableExtensions.<Diagnostic>head(this.getDiagnostics().get(firstFile)).getMessage()); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("type Foo {"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); final String path = this.writeFile("MyType2.testlang", _builder_1); WorkspaceService _workspaceService = this.languageServer.getWorkspaceService(); FileEvent _fileEvent = new FileEvent(path, FileChangeType.Created); DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams( Collections.<FileEvent>unmodifiableList(CollectionLiterals.<FileEvent>newArrayList(_fileEvent))); _workspaceService.didChangeWatchedFiles(_didChangeWatchedFilesParams); this.assertEquals("Couldn\'t resolve reference to TypeDeclaration \'NonExisting\'.", IterableExtensions.<Diagnostic>head(this.getDiagnostics().get(firstFile)).getMessage()); StringConcatenation _builder_2 = new StringConcatenation(); _builder_2.append("type NonExisting {"); _builder_2.newLine(); _builder_2.append("}"); _builder_2.newLine(); this.open(path, _builder_2.toString()); Assert.assertNull(IterableExtensions.<Diagnostic>head(this.getDiagnostics().get(firstFile))); this.close(path); this.assertEquals("Couldn\'t resolve reference to TypeDeclaration \'NonExisting\'.", IterableExtensions.<Diagnostic>head(this.getDiagnostics().get(firstFile)).getMessage()); }
@Test public void testIncrementalBuildWithError() { StringConcatenation _builder = new StringConcatenation(); _builder.append("type Test {"); _builder.newLine(); _builder.append(" "); _builder.append("NonExisting foo"); _builder.newLine(); _builder.append("}"); _builder.newLine(); this.writeFile("MyType1.testlang", _builder); this.initialize(); this.assertEquals("Couldn\'t resolve reference to TypeDeclaration \'NonExisting\'.", IterableExtensions.<Diagnostic>head(IterableExtensions.<List<Diagnostic>>head(this.getDiagnostics().values())).getMessage()); StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append("type NonExisting {"); _builder_1.newLine(); _builder_1.append("}"); _builder_1.newLine(); final String path = this.writeFile("MyType2.testlang", _builder_1); WorkspaceService _workspaceService = this.languageServer.getWorkspaceService(); FileEvent _fileEvent = new FileEvent(path, FileChangeType.Created); DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams(Collections.<FileEvent>unmodifiableList(CollectionLiterals.<FileEvent>newArrayList(_fileEvent))); _workspaceService.didChangeWatchedFiles(_didChangeWatchedFilesParams); Assert.assertNotNull(this.getDiagnostics().get(path)); final Function1<List<Diagnostic>, Boolean> _function = (List<Diagnostic> it) -> { return Boolean.valueOf(it.isEmpty()); }; Assert.assertTrue(IterableExtensions.join(this.getDiagnostics().values(), ","), IterableExtensions.<List<Diagnostic>>forall(this.getDiagnostics().values(), _function)); }
@Override public void didChangeWatchedFiles(final DidChangeWatchedFilesParams params) { final Function0<BuildManager.Buildable> _function = () -> { BuildManager.Buildable _xblockexpression = null; { final ArrayList<URI> dirtyFiles = CollectionLiterals.<URI>newArrayList(); final ArrayList<URI> deletedFiles = CollectionLiterals.<URI>newArrayList(); List<FileEvent> _changes = params.getChanges(); for (final FileEvent fileEvent : _changes) { FileChangeType _type = fileEvent.getType(); boolean _tripleEquals = (_type == FileChangeType.Deleted); if (_tripleEquals) { URI _uri = this._uriExtensions.toUri(fileEvent.getUri()); deletedFiles.add(_uri); } else { URI _uri_1 = this._uriExtensions.toUri(fileEvent.getUri()); dirtyFiles.add(_uri_1); } } _xblockexpression = this.workspaceManager.didChangeFiles(dirtyFiles, deletedFiles); } return _xblockexpression; }; final Function2<CancelIndicator, BuildManager.Buildable, List<IResourceDescription.Delta>> _function_1 = (CancelIndicator cancelIndicator, BuildManager.Buildable buildable) -> { return buildable.build(cancelIndicator); }; this.requestManager.<BuildManager.Buildable, List<IResourceDescription.Delta>>runWrite(_function, _function_1); }
@Override public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { List<FileEvent> settings = params.getChanges(); LOGGER.info("SERVER: changeWatchedFiles: size -> {0}", settings.size()); }
@Override public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { }
@Override public void didChangeWatchedFiles(final DidChangeWatchedFilesParams params) { // TODO Auto-generated method stub }
@Override public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { logInfo(">> workspace/didChangeWatchedFiles"); WorkspaceEventsHandler handler = new WorkspaceEventsHandler(pm, client); handler.didChangeWatchedFiles(params); }
private void send(LanguageServer server, String filePath, FileChangeType changeType) { DidChangeWatchedFilesParams params = new DidChangeWatchedFilesParams( Collections.singletonList(new FileEvent(prefixURI(filePath), changeType))); server.getWorkspaceService().didChangeWatchedFiles(params); }
@JsonNotification("workspace/didChangeWatchedFiles") void didChangeWatchedFiles(DidChangeWatchedFilesParams params);
/** * The watched files notification is sent from the client to the server when * the client detects changes to file watched by the language client. */ @JsonNotification void didChangeWatchedFiles(DidChangeWatchedFilesParams params);