use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.
the class AbstractIdeTest method changeFilesOnDiskWithoutNotification.
/**
* Same as {@link #changeFileOnDiskWithoutNotification(FileURI, Function)}, but changes one or more files at once,
* as defined by the given {@link WorkspaceEdit}.
*/
protected List<Pair<FileURI, List<TextEdit>>> changeFilesOnDiskWithoutNotification(WorkspaceEdit workspaceEdit) {
List<Either<TextDocumentEdit, ResourceOperation>> documentChanges = workspaceEdit.getDocumentChanges();
if (documentChanges != null && !documentChanges.isEmpty()) {
List<Pair<FileURI, List<TextEdit>>> appliedChanges = new ArrayList<>();
for (Either<TextDocumentEdit, ResourceOperation> documentChange : documentChanges) {
if (documentChange.isRight()) {
throw new UnsupportedOperationException("resource operations not yet supported by AbstractIdeTest");
}
TextDocumentEdit edit = documentChange.getLeft();
if (edit.getTextDocument().getVersion() != null) {
throw new UnsupportedOperationException("text document versions not yet supported by AbstractIdeTest");
}
FileURI fileURI = getFileURIFromURIString(edit.getTextDocument().getUri());
changeFileOnDiskWithoutNotification(fileURI, edit.getEdits());
appliedChanges.add(Pair.of(fileURI, edit.getEdits()));
}
return appliedChanges;
}
Map<String, List<TextEdit>> changes = workspaceEdit.getChanges();
if (changes != null && !changes.isEmpty()) {
List<Pair<FileURI, List<TextEdit>>> appliedChanges = new ArrayList<>();
for (Entry<String, List<TextEdit>> entry : changes.entrySet()) {
FileURI fileURI = getFileURIFromURIString(entry.getKey());
changeFileOnDiskWithoutNotification(fileURI, entry.getValue());
appliedChanges.add(Pair.of(fileURI, entry.getValue()));
}
return appliedChanges;
}
List<Either<ResourceChange, TextDocumentEdit>> resourceChanges = workspaceEdit.getResourceChanges();
if (resourceChanges != null && !resourceChanges.isEmpty()) {
throw new UnsupportedOperationException("deprecated property 'WorkspaceEdit#resourceChanges' is not supported");
}
throw new IllegalArgumentException("workspace edit without changes");
}
use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.
the class AbstractIdeTest method changeFileOnDiskWithoutNotification.
/**
* Same as {@link #changeFileOnDiskWithoutNotification(FileURI, Pair...)}, accepting a module name instead of a file
* URI.
*/
@SafeVarargs
protected final void changeFileOnDiskWithoutNotification(String moduleName, Pair<String, ? extends CharSequence>... replacements) {
FileURI fileURI = getFileURIFromModuleName(moduleName);
changeFileOnDiskWithoutNotification(fileURI, replacements);
}
use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.
the class AbstractIdeTest method renameFileOnDiskWithoutNotification.
/**
* Same as {@link #renameFileOnDiskWithoutNotification(FileURI, String)}, accepting a module name.
*/
protected void renameFileOnDiskWithoutNotification(String moduleName, String newFileNameIncludingExtension) {
FileURI fileURI = getFileURIFromModuleName(moduleName);
renameFileOnDiskWithoutNotification(fileURI, newFileNameIncludingExtension);
}
use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.
the class AbstractIdeTest method moveFile.
/**
* Moves the given file or folder to the new location and notifies the server.
*/
protected void moveFile(FileURI fileURI, File newLocation) {
FileURI newFileURI = toFileURI(newLocation).appendSegment(fileURI.getName());
internalMoveFile(fileURI, newFileURI, true);
}
use of org.eclipse.n4js.workspace.locations.FileURI in project n4js by eclipse.
the class AbstractIdeTest method renameFileOnDiskWithoutNotification.
/**
* Rename an existing file on disk without notifying the LSP server about it.
*/
protected void renameFileOnDiskWithoutNotification(FileURI fileURI, String newFileNameIncludingExtension) {
FileURI fileURIRenamed = fileURI.getParent().appendSegment(newFileNameIncludingExtension);
internalMoveFile(fileURI, fileURIRenamed, false);
}
Aggregations