Skip to content
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
2 changes: 1 addition & 1 deletion bundles/org.eclipse.core.filebuffers/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.filebuffers; singleton:=true
Bundle-Version: 3.8.600.qualifier
Bundle-Version: 3.8.700.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public IStatus getStatus() {
}

private InputStream getFileContents(IFileStore fileStore) throws CoreException {
if (!fFileStore.fetchInfo().exists()) {
if (!fFileStore.exists()) {
return null;
}

Expand Down Expand Up @@ -418,8 +418,7 @@ protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwri
throw new CoreException(s);
}

IFileInfo fileInfo= fFileStore.fetchInfo();
if (fileInfo != null && fileInfo.exists()) {
if (fFileStore.exists()) {

if (!overwrite) {
checkSynchronizationState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.util.Map;

import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.filesystem.URIUtil;

Expand Down Expand Up @@ -276,8 +275,7 @@ protected boolean isTextFileLocation(IFileStore fileStore, boolean strict) {
}

IContentTypeManager manager= Platform.getContentTypeManager();
IFileInfo fileInfo= fileStore.fetchInfo();
if (fileInfo.exists()) {
if (fileStore.exists()) {

try(InputStream is= fileStore.openInputStream(EFS.NONE, null)) {
IContentDescription description= manager.getDescriptionFor(is, fileStore.getName(), IContentDescription.ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.ltk.internal.core.refactoring.history;

import static org.eclipse.ltk.internal.core.refactoring.history.RefactoringHistoryService.exists;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
Expand Down Expand Up @@ -785,7 +787,7 @@ void addRefactoringDescriptor(final RefactoringDescriptor descriptor, final bool
final IFileStore history= folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);
final IFileStore index= folder.getChild(RefactoringHistoryService.NAME_INDEX_FILE);
final RefactoringDescriptorProxy[] proxies= new RefactoringDescriptorProxy[] { new DefaultRefactoringDescriptorProxy(descriptor.getDescription(), descriptor.getProject(), descriptor.getTimeStamp())};
if (history.fetchInfo(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(history, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK))) {
InputStream input= null;
try {
input= new BufferedInputStream(history.openInputStream(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)));
Expand Down Expand Up @@ -933,11 +935,11 @@ RefactoringHistory readRefactoringHistory(final long start, final long end, fina
SubMonitor subMon= SubMonitor.convert(monitor, RefactoringCoreMessages.RefactoringHistoryService_retrieving_history, 200);
final Set<RefactoringDescriptorProxy> set= new HashSet<>();
try {
if (fHistoryStore.fetchInfo(EFS.NONE, subMon.newChild(20, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(fHistoryStore, subMon.newChild(20, SubMonitor.SUPPRESS_SUBTASK))) {
readRefactoringDescriptorProxies(fHistoryStore, fProjectName, set, start, end, subMon.newChild(80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
}
final IFileStore store= EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(RefactoringHistoryService.NAME_HISTORY_FOLDER).getChild(RefactoringHistoryService.NAME_WORKSPACE_PROJECT);
if (store.fetchInfo(EFS.NONE, subMon.newChild(20, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(store, subMon.newChild(20, SubMonitor.SUPPRESS_SUBTASK))) {
readRefactoringDescriptorProxies(store, null, set, start, end, subMon.newChild(80), RefactoringCoreMessages.RefactoringHistoryService_retrieving_history);
}
} catch (CoreException exception) {
Expand Down Expand Up @@ -974,29 +976,19 @@ private void removeRefactoringDescriptors(final RefactoringDescriptorProxy[] pro
SubMonitor subMon= SubMonitor.convert(monitor, task, 5);
final IFileStore folder= fHistoryStore.getFileStore(path);
final IFileStore index= folder.getChild(RefactoringHistoryService.NAME_INDEX_FILE);
if (index.fetchInfo(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(index, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK))) {
final Set<RefactoringDescriptorProxy> resultingProxies= new HashSet<>(64);
readRefactoringDescriptorProxies(index, null, resultingProxies, 0, Long.MAX_VALUE, subMon.newChild(1), task);
if (resultingProxies.size() == proxies.length) {
removeIndexTree(folder, subMon.newChild(1), task);
} else {
final IFileStore history= folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);
if (history.fetchInfo(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
InputStream input= null;
if (exists(history, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK))) {
Document document= null;
try {
input= new BufferedInputStream(history.openInputStream(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)));
try (InputStream input= new BufferedInputStream(history.openInputStream(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)));) {
document= getCachedDocument(path, input);
} catch (ParserConfigurationException | IOException | SAXException exception) {
throw createCoreException(exception);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException exception) {
// Do nothing
}
}
}
final Set<Node> removedNodes= new HashSet<>(proxies.length);
final NodeList list= document.getElementsByTagName(IRefactoringSerializationConstants.ELEMENT_REFACTORING);
Expand Down Expand Up @@ -1091,7 +1083,7 @@ RefactoringDescriptor requestDescriptor(final RefactoringDescriptorProxy proxy,
try {
final IFileStore folder= fHistoryStore.getFileStore(stampToPath(stamp));
final IFileStore file= folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);
if (file.fetchInfo(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(file, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK))) {
input= new BufferedInputStream(file.openInputStream(EFS.NONE, subMon.newChild(1, SubMonitor.SUPPRESS_SUBTASK)));
final RefactoringSessionDescriptor descriptor= getCachedSession(file, fProjectName, input);
if (descriptor != null) {
Expand Down Expand Up @@ -1141,14 +1133,11 @@ void setComment(final RefactoringDescriptorProxy proxy, final String comment, fi
final IPath path= stampToPath(stamp);
final IFileStore folder= fHistoryStore.getFileStore(path);
final IFileStore history= folder.getChild(RefactoringHistoryService.NAME_HISTORY_FILE);
if (history.fetchInfo(EFS.NONE, subMonitor.newChild(20, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
InputStream input= null;
try {
input= new BufferedInputStream(history.openInputStream(EFS.NONE, subMonitor.newChild(40, SubMonitor.SUPPRESS_SUBTASK)));
if (exists(history, subMonitor.newChild(20, SubMonitor.SUPPRESS_SUBTASK))) {
try (InputStream input= new BufferedInputStream(history.openInputStream(EFS.NONE, subMonitor.newChild(40, SubMonitor.SUPPRESS_SUBTASK)));) {
final Document document= getCachedDocument(path, input);
try {
input.close();
input= null;
} catch (IOException exception) {
// Do nothing
}
Expand All @@ -1165,14 +1154,6 @@ void setComment(final RefactoringDescriptorProxy proxy, final String comment, fi
writeHistoryEntry(history, document, subMonitor.newChild(40, SubMonitor.SUPPRESS_SUBTASK), RefactoringCoreMessages.RefactoringHistoryService_updating_history);
} catch (ParserConfigurationException | IOException | SAXException exception) {
throw createCoreException(exception);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException exception) {
// Do nothing
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ public static void setSharedRefactoringHistory(final IProject project, final boo
final IFileStore history= EFS.getLocalFileSystem().getStore(RefactoringCorePlugin.getDefault().getStateLocation()).getChild(NAME_HISTORY_FOLDER);
if (enable) {
final IFileStore source= history.getChild(name);
if (source.fetchInfo(EFS.NONE, subMonitor.newChild(20)).exists()) {
if (exists(source, subMonitor.newChild(20))) {
IFileStore destination= EFS.getStore(uri).getChild(NAME_HISTORY_FOLDER);
if (destination.fetchInfo(EFS.NONE, subMonitor.newChild(20)).exists()) {
if (exists(destination, subMonitor.newChild(20))) {
destination.delete(EFS.NONE, subMonitor.newChild(20));
}
destination.mkdir(EFS.NONE, subMonitor.newChild(20));
Expand All @@ -262,9 +262,9 @@ public static void setSharedRefactoringHistory(final IProject project, final boo
}
} else {
final IFileStore source= EFS.getStore(uri).getChild(NAME_HISTORY_FOLDER);
if (source.fetchInfo(EFS.NONE, subMonitor.newChild(20)).exists()) {
if (exists(source, subMonitor.newChild(20))) {
IFileStore destination= history.getChild(name);
if (destination.fetchInfo(EFS.NONE, subMonitor.newChild(20)).exists()) {
if (exists(destination, subMonitor.newChild(20))) {
destination.delete(EFS.NONE, subMonitor.newChild(20));
}
destination.mkdir(EFS.NONE, subMonitor.newChild(20));
Expand Down Expand Up @@ -848,9 +848,9 @@ private void moveHistory(final IProject oldProject, final IProject newProject, f
final String oldName= oldProject.getName();
final String newName= newProject.getName();
final IFileStore oldStore= historyStore.getChild(oldName);
if (oldStore.fetchInfo(EFS.NONE, subMonitor.newChild(10, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(oldStore, subMonitor.newChild(10, SubMonitor.SUPPRESS_SUBTASK))) {
final IFileStore newStore= historyStore.getChild(newName);
if (newStore.fetchInfo(EFS.NONE, subMonitor.newChild(10, SubMonitor.SUPPRESS_SUBTASK)).exists()) {
if (exists(newStore, subMonitor.newChild(10, SubMonitor.SUPPRESS_SUBTASK))) {
newStore.delete(EFS.NONE, subMonitor.newChild(20, SubMonitor.SUPPRESS_SUBTASK));
}
oldStore.move(newStore, EFS.OVERWRITE, subMonitor.newChild(20, SubMonitor.SUPPRESS_SUBTASK));
Expand All @@ -862,6 +862,13 @@ private void moveHistory(final IProject oldProject, final IProject newProject, f
}
}

/**
* @param monitor just accepted to allow callers to consume the monitors ticks
*/
static boolean exists(IFileStore store, IProgressMonitor monitor) {
return store.exists();
}

private void peformResourceChanged(final IResourceChangeEvent event) {
final int type= event.getType();
if ((type & IResourceChangeEvent.POST_CHANGE) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public boolean test(final Object receiver, final String property, final Object[]
if (resource instanceof final IProject project) {
final IFileStore store= getHistoryStore(project);
if (store != null) {
return store.fetchInfo().exists();
return store.exists();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ public boolean isDeleted(Object element) {
FileInfo info= fFileInfoMap.get(element);
if (info != null) {
IFileStore fileStore= getFileStore(info);
return fileStore == null ? true : !fileStore.fetchInfo().exists();
return fileStore == null || !fileStore.exists();
}
return getParentProvider().isDeleted(element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ IStatus checkExist(IFileStore[] stores) {
IStatus.OK, getProblemsMessage(), null);

for (IFileStore store : stores) {
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
String message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted,
store.getName());
IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public IFile createNewFile() {
try {
if (resolvedPath.getScheme() != null && resolvedPath.getSchemeSpecificPart() != null) {
IFileStore store = EFS.getStore(resolvedPath);
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
MessageDialog dlg = new MessageDialog(getContainer().getShell(),
IDEWorkbenchMessages.WizardNewFileCreationPage_createLinkLocationTitle, null,
NLS.bind(IDEWorkbenchMessages.WizardNewFileCreationPage_createLinkLocationQuestion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public IFolder createNewFolder() {
URI resolvedPath = newFolderHandle.getPathVariableManager().resolveURI(linkTargetPath);
try {
IFileStore store = EFS.getStore(resolvedPath);
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
MessageDialog dlg = new MessageDialog(getContainer().getShell(),
IDEWorkbenchMessages.WizardNewFolderCreationPage_createLinkLocationTitle, null,
NLS.bind(IDEWorkbenchMessages.WizardNewFolderCreationPage_createLinkLocationQuestion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,14 @@ private void handleLinkTargetBrowseButtonPressed() {
IFileStore store = null;
if (linkTargetName.length() > 0) {
store = IDEResourceInfoUtils.getFileStore(linkTargetName);
if (store == null || !store.fetchInfo().exists()) {
if (store == null || !store.exists()) {
store = null;
}
}
if (type == IResource.FILE) {
FileDialog dialog = new FileDialog(getShell(), SWT.SHEET);
if (store != null) {
if (store.fetchInfo().isDirectory()) {
if (store.isDirectory()) {
dialog.setFilterPath(linkTargetName);
} else {
dialog.setFileName(linkTargetName);
Expand All @@ -226,7 +226,7 @@ private void handleLinkTargetBrowseButtonPressed() {
} else {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SHEET);
if (store != null) {
if (!store.fetchInfo().isDirectory()) {
if (!store.isDirectory()) {
linkTargetName = store.getParent().getName();
}
if (linkTargetName != null) {
Expand Down Expand Up @@ -294,10 +294,10 @@ public void setLinkTarget(String target) {
private boolean validateFileType(IFileStore linkTargetStore) {
boolean valid = true;

if (type == IResource.FILE && linkTargetStore.fetchInfo().isDirectory()) {
if (type == IResource.FILE && linkTargetStore.isDirectory()) {
setErrorMessage(IDEWorkbenchMessages.WizardNewLinkPage_linkTargetNotFile);
valid = false;
} else if (type == IResource.FOLDER && !linkTargetStore.fetchInfo().isDirectory()) {
} else if (type == IResource.FOLDER && !linkTargetStore.isDirectory()) {
setErrorMessage(IDEWorkbenchMessages.WizardNewLinkPage_linkTargetNotFolder);
valid = false;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ private boolean validatePage() {
valid = validateLinkTargetName(linkTargetName);
if (valid) {
IFileStore linkTargetFile = IDEResourceInfoUtils.getFileStore(linkTargetName);
if (linkTargetFile == null || !linkTargetFile.fetchInfo().exists()) {
if (linkTargetFile == null || !linkTargetFile.exists()) {
setErrorMessage(IDEWorkbenchMessages.WizardNewLinkPage_linkTargetNonExistent);
valid = false;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public FileStoreEditorInput(IFileStore fileStore) {

@Override
public boolean exists() {
return fileStore.fetchInfo().exists();
return fileStore.exists();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ private void handleLinkTargetBrowseButtonPressed() {

if (linkTarget.length() > 0) {
store = IDEResourceInfoUtils.getFileStore(linkTarget);
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
store = null;
}
}
Expand All @@ -476,7 +476,7 @@ private void handleLinkTargetBrowseButtonPressed() {
FileDialog dialog = new FileDialog(linkTargetField.getShell(), SWT.SHEET);
dialog.setText(IDEWorkbenchMessages.CreateLinkedResourceGroup_targetSelectionTitle);
if (store != null) {
if (store.fetchInfo().isDirectory()) {
if (store.isDirectory()) {
dialog.setFilterPath(linkTarget);
} else {
dialog.setFileName(linkTarget);
Expand All @@ -494,7 +494,7 @@ private void handleLinkTargetBrowseButtonPressed() {
String filterPath = null;
if (store != null) {
IFileStore path = store;
if (!store.fetchInfo().isDirectory()) {
if (!store.isDirectory()) {
path = store.getParent();
}
if (path != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private static class FileLabelProvider extends LabelProvider {
@Override
public Image getImage(Object element) {
if (element instanceof IFileStore curr) {
if (curr.fetchInfo().isDirectory()) {
if (curr.isDirectory()) {
return IMG_FOLDER;
}
return IMG_FILE;
Expand Down Expand Up @@ -85,12 +85,7 @@ private static class FileContentProvider implements ITreeContentProvider {
* receiver. <code>false</code> only folders are returned.
*/
public FileContentProvider(final boolean showFiles) {
fileFilter = file -> {
if (!file.fetchInfo().isDirectory() && !showFiles) {
return false;
}
return true;
};
fileFilter = file -> showFiles || file.isDirectory();
}

@Override
Expand Down Expand Up @@ -139,8 +134,7 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
private static class FileViewerSorter extends ViewerComparator {
@Override
public int category(Object element) {
if (element instanceof IFileStore
&& !((IFileStore) element).fetchInfo().isDirectory()) {
if (element instanceof IFileStore fileStore && !fileStore.isDirectory()) {
return 1;
}
return 0;
Expand Down Expand Up @@ -182,7 +176,7 @@ public IStatus validate(Object[] selection) {
}
for (Object currentSelection : selection) {
if (currentSelection instanceof IFileStore file) {
if (!acceptFolders && file.fetchInfo().isDirectory()) {
if (!acceptFolders && file.isDirectory()) {
return new Status(IStatus.ERROR, pluginId,
IStatus.ERROR,
IDEResourceInfoUtils.EMPTY_STRING, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static String getLocationText(IResource resource) {
if (store == null) {
return UNKNOWN_LABEL;
}
if (!store.fetchInfo().exists()) {
if (!store.exists()) {
return NLS.bind(FILE_NOT_EXIST_TEXT, store.toString());
}
}
Expand Down Expand Up @@ -300,7 +300,7 @@ public static String getResolvedLocationText(IResource resource) {
}

// don't access the file system for closed projects (bug 151089)
if (isProjectAccessible(resource) && !store.fetchInfo().exists()) {
if (isProjectAccessible(resource) && !store.exists()) {
return NLS.bind(FILE_NOT_EXIST_TEXT, store.toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ boolean exists(IResource res) throws CoreException {
URI uri = res.getLocationURI();
if (uri != null) {
IFileStore fileStore = EFS.getStore(uri);
return (fileStore != null) && fileStore.fetchInfo().exists();
return fileStore != null && fileStore.exists();
}
return false;
}
Expand Down
Loading
Loading