Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated getPath method and use getLocation instead #3322

Merged
merged 1 commit into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
@Beta
public interface File extends Resource, VirtualFile, ModificationTracker {

/** @see VirtualFile#getPath() */
@Override
String getPath();

/** @see VirtualFile#getDisplayName() */
@Override
String getDisplayName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ public SyntheticFile(String name, String displayName, String content) {
this.content = content;
}

@Override
public String getPath() {
return name;
}

@Override
public Path getLocation() {
return Path.valueOf(getPath());
return Path.valueOf(name);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,6 @@
*/
public interface VirtualFile {

/**
* Returns path for the virtual file. Path may in various representation based on implementation.
* Usually it something like physical file or folder path, e.g. `/path/to/som/file`.
* Path should always be non-null or non-empty.
*
* @return non-null unique path.
* @deprecated use {@link #getLocation()}
*/
@Deprecated
String getPath();

/**
* Returns path for the virtual file. Path may in various representation based on implementation.
* Usually it something like physical file or folder path, e.g. `/path/to/som/file`.
Expand All @@ -46,7 +35,6 @@ public interface VirtualFile {
* @return non-null unique path.
* @since 4.4.0
*/
@Beta
Path getLocation();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.che.ide.api.event.FileEvent;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.resources.File;
import org.eclipse.che.ide.resource.Path;
import org.eclipse.che.ide.util.loging.Log;

import static org.eclipse.che.api.promises.client.callback.CallbackPromiseHelper.createFromCallback;
Expand Down Expand Up @@ -125,7 +126,7 @@ public void onActivePartChanged(ActivePartChangedEvent event) {
if (event.getActivePart() instanceof EditorPartPresenter) {
EditorPartPresenter editor = (EditorPartPresenter)event.getActivePart();
handlerRegistration.removeHandler();
if ((pathToOpen).equals(editor.getEditorInput().getFile().getPath())) {
if (Path.valueOf(pathToOpen).equals(editor.getEditorInput().getFile().getLocation())) {
callback.onSuccess(null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void changeBreakpointState(final int lineNumber) {

final VirtualFile activeFile = editor.getEditorInput().getFile();

List<Breakpoint> pathBreakpoints = breakpoints.get(activeFile.getPath());
List<Breakpoint> pathBreakpoints = breakpoints.get(activeFile.getLocation().toString());
if (pathBreakpoints != null) {
for (final Breakpoint breakpoint : pathBreakpoints) {
if (breakpoint.getLineNumber() == lineNumber) {
Expand All @@ -133,7 +133,7 @@ public void changeBreakpointState(final int lineNumber) {
if (isLineNotEmpty(activeFile, lineNumber)) {
Breakpoint breakpoint = new Breakpoint(BREAKPOINT,
lineNumber,
activeFile.getPath(),
activeFile.getLocation().toString(),
activeFile,
false);
addBreakpoint(breakpoint);
Expand Down Expand Up @@ -234,7 +234,7 @@ public void onLineChange(VirtualFile file, int firstLine, int linesAdded, int li
* Indicates if line of code to add breakpoint at is executable.
*/
private boolean isLineNotEmpty(final VirtualFile activeFile, int lineNumber) {
EditorPartPresenter editor = getEditorForFile(activeFile.getPath());
EditorPartPresenter editor = getEditorForFile(activeFile.getLocation().toString());
if (editor instanceof TextEditor) {
Document document = ((TextEditor)editor).getDocument();
return !document.getLineContent(lineNumber).trim().isEmpty();
Expand Down Expand Up @@ -273,9 +273,9 @@ private void setCurrentBreakpoint(String filePath, int lineNumber) {
}

private void doSetCurrentBreakpoint(VirtualFile activeFile, int lineNumber) {
currentBreakpoint = new Breakpoint(Type.CURRENT, lineNumber, activeFile.getPath(), activeFile, true);
currentBreakpoint = new Breakpoint(Type.CURRENT, lineNumber, activeFile.getLocation().toString(), activeFile, true);

BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(activeFile.getPath());
BreakpointRenderer breakpointRenderer = getBreakpointRendererForFile(activeFile.getLocation().toString());
if (breakpointRenderer != null) {
breakpointRenderer.setLineActive(lineNumber, true);
}
Expand Down Expand Up @@ -347,11 +347,11 @@ private BreakpointRenderer getBreakpointRendererForEditor(final EditorPartPresen
*/
@Override
public void onLineChange(final VirtualFile file, final int firstLine, final int linesAdded, final int linesRemoved) {
final List<Breakpoint> fileBreakpoints = breakpoints.get(file.getPath());
final List<Breakpoint> fileBreakpoints = breakpoints.get(file.getLocation().toString());
final int delta = linesAdded - linesRemoved;

if (fileBreakpoints != null) {
LOG.fine("Change in file with breakpoints " + file.getPath());
LOG.fine("Change in file with breakpoints " + file.getLocation().toString());

final List<Breakpoint> toRemove = new ArrayList<>();
final List<Breakpoint> toAdd = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.che.ide.api.event.FileEvent.FileEventHandler;
import org.eclipse.che.ide.api.machine.WsAgentURLModifier;
import org.eclipse.che.ide.api.parts.WorkspaceAgent;
import org.eclipse.che.ide.resource.Path;
import org.vectomatic.dom.svg.ui.SVGResource;

import javax.validation.constraints.NotNull;
Expand Down Expand Up @@ -184,8 +185,8 @@ public void onFileOperation(FileEvent event) {
return;
}

final String eventFilePath = event.getFile().getPath();
final String filePath = input.getFile().getPath();
final Path eventFilePath = event.getFile().getLocation();
final Path filePath = input.getFile().getLocation();
if (filePath.equals(eventFilePath)) {
workspaceAgent.removePart(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public void actionPerformed(ActionEvent e) {
* @return action id
*/
public String getId() {
return "recent/" + file.getPath();
return "recent/" + file.getLocation();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public String getDisplayName() {
}
}

/** {@inheritDoc} */
@Override
public String getPath() {
return getLocation().toString();
}

/** {@inheritDoc} */
@Override
public String getExtension() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -890,8 +890,8 @@ private boolean isResourceOpened(final Resource resource) {
File file = (File)resource;

for (EditorPartPresenter editor : editorAgent.getOpenedEditors()) {
String editorPath = editor.getEditorInput().getFile().getLocation().toString();
if (editorPath.equals(file.getPath())) {
Path editorPath = editor.getEditorInput().getFile().getLocation();
if (editorPath.equals(file.getLocation())) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public void onFailure(Throwable caught) {
@Override
public void onSuccess(VirtualFile result) {
for (DebuggerObserver observer : observers) {
observer.onBreakpointStopped(result.getPath(),
observer.onBreakpointStopped(result.getLocation().toString(),
currentLocation.getTarget(),
currentLocation.getLineNumber());
}
Expand Down Expand Up @@ -351,7 +351,7 @@ public void apply(PromiseError arg) throws OperationException {
}
});
} else {
Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getPath(), file, false);
Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
for (DebuggerObserver observer : observers) {
observer.onBreakpointAdded(breakpoint);
}
Expand All @@ -377,7 +377,7 @@ public void deleteBreakpoint(final VirtualFile file, final int lineNumber) {
@Override
public void apply(Void arg) throws OperationException {
for (DebuggerObserver observer : observers) {
Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getPath(), file, false);
Breakpoint breakpoint = new Breakpoint(Breakpoint.Type.BREAKPOINT, lineNumber, file.getLocation().toString(), file, false);
observer.onBreakpointDeleted(breakpoint);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void setUp() {
doReturn(DEBUG_INFO).when(localStorage).getItem(AbstractDebugger.LOCAL_STORAGE_DEBUGGER_SESSION_KEY);
doReturn(debugSessionDto).when(dtoFactory).createDtoFromJson(anyString(), eq(DebugSessionDto.class));

doReturn(PATH).when(file).getPath();
doReturn(Path.valueOf(PATH)).when(file).getLocation();

debugger = new TestDebugger(service, dtoFactory, localStorageProvider, messageBusProvider, eventBus,
activeFileHandler, debuggerManager, "id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void apply(Void ignored) throws OperationException {
parent.get().synchronize();
}

eventBus.fireEvent(new FileContentUpdateEvent(comparedFile.getPath()));
eventBus.fireEvent(new FileContentUpdateEvent(comparedFile.getLocation().toString()));
view.hide();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void openFile(Location location, AsyncCallback<VirtualFile> callback) {
final EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
if (activeEditor != null) {
activeFile = editorAgent.getActiveEditor().getEditorInput().getFile();
activePath = activeFile.getPath();
activePath = activeFile.getLocation().toString();
}
if (activePath != null && !activePath.equals(location.getTarget()) && !activePath.equals(location.getResourcePath())) {
if (location.isExternalResource()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public class JavaClassFqnResolver implements FqnResolver {
@NotNull
@Override
public String resolveFqn(@NotNull final VirtualFile file) {
return file.getPath();
return file.getLocation().toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,9 @@ public boolean isLeaf() {
return true;
}

/** {@inheritDoc} */
@NotNull
@Override
public String getPath() {
return getData().getPath();
}

@Override
public Path getLocation() {
return Path.valueOf(getPath());
return Path.valueOf(getData().getPath());
}

/** {@inheritDoc} */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void acceptButtonActionShouldBeNotPerformedIfStatusIsNotOK() throws Excep
verify(view, never()).hide();
verify(editor, never()).getEditorInput();
verify(editorInput, never()).getFile();
verify(virtualFile, never()).getPath();
verify(virtualFile, never()).getLocation();
verify(view).showErrorMessage(refactoringStatus);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ private void onOpen(final FileEvent event,
@Override
public void apply(String text) throws OperationException {
TextDocumentItemDTO documentItem = dtoFactory.createDto(TextDocumentItemDTO.class);
documentItem.setUri(event.getFile().getPath());
documentItem.setUri(event.getFile().getLocation().toString());
documentItem.setVersion(LanguageServerEditorConfiguration.INITIAL_DOCUMENT_VERSION);
documentItem.setText(text);

DidOpenTextDocumentParamsDTO openEvent = dtoFactory.createDto(DidOpenTextDocumentParamsDTO.class);
openEvent.setTextDocument(documentItem);
openEvent.setUri(event.getFile().getPath());
openEvent.setUri(event.getFile().getLocation().toString());
openEvent.setText(text);

serviceClient.didOpen(openEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public Promise<EditorPartPresenter> createEditor(VirtualFile file) {
File resource = (File)file;

Promise<InitializeResult> promise =
registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getPath());
registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
loader.show();
return promise.thenPromise(new Function<InitializeResult, Promise<EditorPartPresenter>>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private void formatFullDocument(Document document) {
DocumentFormattingParamsDTO params = dtoFactory.createDto(DocumentFormattingParamsDTO.class);

TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifier.setUri(document.getFile().getPath());
identifier.setUri(document.getFile().getLocation().toString());

params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
Expand Down Expand Up @@ -189,7 +189,7 @@ private void formatRange(TextRange selectedRange, Document document) {
DocumentRangeFormattingParamsDTO params = dtoFactory.createDto(DocumentRangeFormattingParamsDTO.class);

TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifier.setUri(document.getFile().getPath());
identifier.setUri(document.getFile().getLocation().toString());

params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public void actionPerformed(ActionEvent e) {
return;
}
TextEditor textEditor = ((TextEditor)activeEditor);
String path = activeEditor.getEditorInput().getFile().getPath();
String path = activeEditor.getEditorInput().getFile().getLocation().toString();
ReferenceParamsDTO paramsDTO = dtoFactory.createDto(ReferenceParamsDTO.class);

PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public GoToSymbolAction(QuickOpenPresenter presenter,
public void actionPerformed(ActionEvent e) {
DocumentSymbolParamsDTO paramsDTO = dtoFactory.createDto(DocumentSymbolParamsDTO.class);
TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
identifierDTO.setUri(editorAgent.getActiveEditor().getEditorInput().getFile().getPath());
identifierDTO.setUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString());
paramsDTO.setTextDocument(identifierDTO);
activeEditor = (TextEditor)editorAgent.getActiveEditor();
cursorPosition = activeEditor.getDocument().getCursorPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public QuickOpenModel apply(List<SymbolEntry> arg) throws FunctionException {
private Promise<List<SymbolEntry>> searchSymbols(final String value) {
WorkspaceSymbolParamsDTO params = dtoFactory.createDto(WorkspaceSymbolParamsDTO.class);
params.setQuery(value);
params.setFileUri(editorAgent.getActiveEditor().getEditorInput().getFile().getPath());
params.setFileUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString());
return workspaceServiceClient.symbol(params).then(new Function<List<SymbolInformationDTO>, List<SymbolEntry>>() {
@Override
public List<SymbolEntry> apply(List<SymbolInformationDTO> types) throws FunctionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void run() {
Set<String> pomPaths = getPomPath(updatedProjects);
List<EditorPartPresenter> openedEditors = editorAgent.getOpenedEditors();
for (EditorPartPresenter openedEditor : openedEditors) {
String path = openedEditor.getEditorInput().getFile().getPath();
String path = openedEditor.getEditorInput().getFile().getLocation().toString();
if (pomPaths.contains(path)) {
if (openedEditor instanceof TextEditor) {
final Reconciler reconciler = ((TextEditor)openedEditor).getConfiguration().getReconciler();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void handleEvent(Event evt) {
}

private void downloadSources(JarFileNode jarFileNode, final HasNotificationPanel.NotificationRemover remover) {
final String path = jarFileNode.getPath();
final String path = jarFileNode.getLocation().toString();
Promise<Boolean> promise = client.downloadSources(jarFileNode.getProjectLocation().toString(), path);
promise.then(new Operation<Boolean>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public PomReconcilingStrategy(@Assisted AnnotationModel annotationModel,

@Override
public void setDocument(Document document) {
pomPath = document.getFile().getPath();
pomPath = document.getFile().getLocation().toString();
}

@Override
Expand Down