Search in sources :

Example 1 with FileChangeType

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

the class LanguageServerImpl method didChangeWatchedFiles.

@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);
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) FileChangeType(org.eclipse.lsp4j.FileChangeType) URI(org.eclipse.emf.common.util.URI) FileEvent(org.eclipse.lsp4j.FileEvent) BuildManager(org.eclipse.xtext.ide.server.BuildManager) ArrayList(java.util.ArrayList) List(java.util.List) CompletionList(org.eclipse.lsp4j.CompletionList) CancelIndicator(org.eclipse.xtext.util.CancelIndicator)

Example 2 with FileChangeType

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

the class ResourceListener method createFileEventFromDelta.

private static FileEvent createFileEventFromDelta(IResourceDelta delta) {
    URI locationURI = LSPEclipseUtils.toUri(delta.getResource());
    if (locationURI == null) {
        return null;
    }
    FileChangeType changeType = null;
    if (delta.getKind() == IResourceDelta.ADDED) {
        changeType = FileChangeType.Created;
    } else if (delta.getKind() == IResourceDelta.CHANGED) {
        changeType = FileChangeType.Changed;
    } else if (delta.getKind() == IResourceDelta.REMOVED) {
        changeType = FileChangeType.Deleted;
    } else {
        // $NON-NLS-1$
        throw new IllegalStateException("Unsupported resource delta kind: " + delta.getKind());
    }
    return new FileEvent(locationURI.toString(), changeType);
}
Also used : FileEvent(org.eclipse.lsp4j.FileEvent) FileChangeType(org.eclipse.lsp4j.FileChangeType) URI(java.net.URI)

Aggregations

FileChangeType (org.eclipse.lsp4j.FileChangeType)2 FileEvent (org.eclipse.lsp4j.FileEvent)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 URI (org.eclipse.emf.common.util.URI)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 BuildManager (org.eclipse.xtext.ide.server.BuildManager)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1 CancelIndicator (org.eclipse.xtext.util.CancelIndicator)1