use of org.eclipse.lsp4j.FileEvent in project xtext-core by eclipse.
the class OpenDocumentTest method testOpenedDocumentShadowsPersistedFile.
@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());
}
use of org.eclipse.lsp4j.FileEvent in project xtext-core by eclipse.
the class ServerTest method testIncrementalBuildWithError.
@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));
}
use of org.eclipse.lsp4j.FileEvent in project xtext-core by eclipse.
the class AbstractLanguageServerTest method didCreateWatchedFiles.
protected void didCreateWatchedFiles(final String... fileUris) {
DidChangeWatchedFilesParams _didChangeWatchedFilesParams = new DidChangeWatchedFilesParams();
final Procedure1<DidChangeWatchedFilesParams> _function = (DidChangeWatchedFilesParams it) -> {
for (final String fileUri : fileUris) {
List<FileEvent> _changes = it.getChanges();
FileEvent _fileEvent = new FileEvent();
final Procedure1<FileEvent> _function_1 = (FileEvent it_1) -> {
it_1.setUri(fileUri);
it_1.setType(FileChangeType.Created);
};
FileEvent _doubleArrow = ObjectExtensions.<FileEvent>operator_doubleArrow(_fileEvent, _function_1);
_changes.add(_doubleArrow);
}
};
DidChangeWatchedFilesParams _doubleArrow = ObjectExtensions.<DidChangeWatchedFilesParams>operator_doubleArrow(_didChangeWatchedFilesParams, _function);
this.languageServer.didChangeWatchedFiles(_doubleArrow);
}
use of org.eclipse.lsp4j.FileEvent in project vscode-nextgenas by BowlerHatLLC.
the class ActionScriptTextDocumentService method didChangeWatchedFiles.
/**
* Called when certain files in the workspace are added, removed, or
* changed, even if they are not considered open for editing. Also checks if
* the project configuration strategy has changed. If it has, checks for
* errors on the whole project.
*/
public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) {
boolean needsFullCheck = false;
for (FileEvent event : params.getChanges()) {
Path path = LanguageServerUtils.getPathFromLanguageServerURI(event.getUri());
if (path == null) {
continue;
}
File file = path.toFile();
String fileName = file.getName();
if ((fileName.endsWith(AS_EXTENSION) || fileName.endsWith(MXML_EXTENSION)) && currentWorkspace != null) {
if (event.getType().equals(FileChangeType.Deleted)) {
IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
currentWorkspace.fileRemoved(fileSpec);
needsFullCheck = true;
} else if (event.getType().equals(FileChangeType.Created)) {
IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
currentWorkspace.fileAdded(fileSpec);
} else if (event.getType().equals(FileChangeType.Changed)) {
IFileSpecification fileSpec = fileSpecGetter.getFileSpecification(file.getAbsolutePath());
currentWorkspace.fileChanged(fileSpec);
checkFilePathForProblems(path, false);
}
}
}
if (needsFullCheck || projectConfigStrategy.getChanged()) {
checkProjectForProblems();
}
}
use of org.eclipse.lsp4j.FileEvent 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);
}
Aggregations