use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class DebuggerTest method testAddBreakpoint.
@Test
public void testAddBreakpoint() throws Exception {
MockSettings mockSettings = new MockSettingsImpl<>().defaultAnswer(RETURNS_SMART_NULLS).extraInterfaces(Resource.class);
Project project = mock(Project.class);
when(optional.isPresent()).thenReturn(true);
when(optional.get()).thenReturn(project);
when(project.getPath()).thenReturn(PATH);
VirtualFile virtualFile = mock(VirtualFile.class, mockSettings);
Path path = mock(Path.class);
when(path.toString()).thenReturn(PATH);
when(virtualFile.getLocation()).thenReturn(path);
when(virtualFile.toString()).thenReturn(PATH);
Resource resource = (Resource) virtualFile;
when(resource.getRelatedProject()).thenReturn(optional);
doReturn(promiseVoid).when(service).addBreakpoint(SESSION_ID, breakpointDto);
doReturn(promiseVoid).when(promiseVoid).then((Operation<Void>) any());
when(locationDto.withLineNumber(LINE_NUMBER + 1)).thenReturn(locationDto);
when(locationDto.withResourcePath(PATH)).thenReturn(locationDto);
when(locationDto.withResourceProjectPath(PATH)).thenReturn(locationDto);
when(locationDto.withTarget(anyString())).thenReturn(locationDto);
when(breakpointDto.withLocation(locationDto)).thenReturn(breakpointDto);
when(breakpointDto.withEnabled(true)).thenReturn(breakpointDto);
debugger.addBreakpoint(virtualFile, LINE_NUMBER);
verify(locationDto).withLineNumber(LINE_NUMBER + 1);
verify(locationDto).withTarget(FQN);
verify(locationDto).withResourcePath(PATH);
verify(locationDto).withResourceProjectPath(PATH);
verify(breakpointDto).withLocation(locationDto);
verify(breakpointDto).withEnabled(true);
verify(promiseVoid).then(operationVoidCaptor.capture());
operationVoidCaptor.getValue().apply(null);
verify(observer).onBreakpointAdded(breakpointCaptor.capture());
assertEquals(breakpointCaptor.getValue(), TEST_BREAKPOINT);
verify(promiseVoid).catchError(operationPromiseErrorCaptor.capture());
operationPromiseErrorCaptor.getValue().apply(promiseError);
verify(promiseError).getMessage();
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class RefactoringUpdater method updateAfterRefactoring.
/**
* Iterates over each refactoring change and according to change type performs specific update operation.
* i.e. for {@code ChangeName#UPDATE} updates only opened editors, for {@code ChangeName#MOVE or ChangeName#RENAME_COMPILATION_UNIT}
* updates only new paths and opened editors, for {@code ChangeName#RENAME_PACKAGE} reloads package structure and restore expansion.
*
* @param changes
* applied changes
*/
public void updateAfterRefactoring(List<ChangeInfo> changes) {
if (changes == null || changes.isEmpty()) {
return;
}
ExternalResourceDelta[] deltas = new ExternalResourceDelta[0];
final List<String> pathChanged = new ArrayList<>();
for (ChangeInfo change : changes) {
final ExternalResourceDelta delta;
final Path newPath = Path.valueOf(change.getPath());
final Path oldPath = !isNullOrEmpty(change.getOldPath()) ? Path.valueOf(change.getOldPath()) : Path.EMPTY;
switch(change.getName()) {
case MOVE:
case RENAME_COMPILATION_UNIT:
delta = new ExternalResourceDelta(newPath, oldPath, ADDED | MOVED_FROM | MOVED_TO);
registerRemovedFile(change);
break;
case RENAME_PACKAGE:
delta = new ExternalResourceDelta(newPath, oldPath, ADDED | MOVED_FROM | MOVED_TO);
break;
case UPDATE:
if (!isFileRemoved(change.getPath(), changes)) {
pathChanged.add(change.getPath());
registerRemovedFile(change);
}
default:
continue;
}
final int index = deltas.length;
deltas = Arrays.copyOf(deltas, index + 1);
deltas[index] = delta;
}
//here we need to remove file for file that moved or renamed JDT lib sent it to
for (int i = 0; i < deltas.length; i++) {
if (pathChanged.contains(deltas[i].getToPath().toString())) {
pathChanged.remove(deltas[i].getToPath().toString());
}
if (pathChanged.contains(deltas[i].getFromPath().toString())) {
pathChanged.remove(deltas[i].getFromPath().toString());
}
}
if (deltas.length > 0) {
appContext.getWorkspaceRoot().synchronize(deltas).then(new Operation<ResourceDelta[]>() {
@Override
public void apply(final ResourceDelta[] appliedDeltas) throws OperationException {
for (ResourceDelta delta : appliedDeltas) {
eventBus.fireEvent(new RevealResourceEvent(delta.getToPath()));
}
for (EditorPartPresenter editorPartPresenter : editorAgent.getOpenedEditors()) {
final String path = editorPartPresenter.getEditorInput().getFile().getLocation().toString();
if (pathChanged.contains(path)) {
eventBus.fireEvent(new FileContentUpdateEvent(editorPartPresenter.getEditorInput().getFile().getLocation().toString()));
}
}
setActiveEditor();
}
});
} else {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
for (EditorPartPresenter editorPartPresenter : editorAgent.getOpenedEditors()) {
eventBus.fireEvent(new FileContentUpdateEvent(editorPartPresenter.getEditorInput().getFile().getLocation().toString()));
}
setActiveEditor();
}
});
}
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class ConvertFolderToProjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent event) {
Resource folder = getSelectedItem();
if (folder == null) {
return;
}
Path location = folder.getLocation();
if (location == null) {
return;
}
MutableProjectConfig mutableProjectConfig = new MutableProjectConfig();
mutableProjectConfig.setPath(location.toString());
mutableProjectConfig.setName(folder.getName());
projectConfigWizard.show(mutableProjectConfig);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class FullTextSearchAction method actionPerformed.
/** {@inheritDoc} */
@Override
public void actionPerformed(ActionEvent e) {
final Resource[] resources = appContext.getResources();
final Path searchPath;
if (resources == null || resources.length == 0 || resources.length > 1) {
searchPath = Path.ROOT;
} else {
if (resources[0] instanceof Container) {
searchPath = resources[0].getLocation();
} else {
final Container parent = resources[0].getParent();
searchPath = parent != null ? parent.getLocation() : Path.ROOT;
}
}
presenter.showDialog(searchPath);
}
use of org.eclipse.che.ide.resource.Path in project che by eclipse.
the class GitServiceClientImpl method remove.
@Override
public Promise<Void> remove(DevMachine devMachine, Path project, Path[] items, boolean cached) {
String params = "?projectPath=" + project.toString();
if (items != null) {
for (Path item : items) {
params += "&items=" + item.toString();
}
}
params += "&cached=" + String.valueOf(cached);
String url = appContext.getDevMachine().getWsAgentBaseUrl() + REMOVE + params;
return asyncRequestFactory.createDeleteRequest(url).loader(loader).send();
}
Aggregations