Skip to content

Commit

Permalink
Merge branch 'eclipse-platform:master' into align_multi_page_editor_tab
Browse files Browse the repository at this point in the history
  • Loading branch information
praveen-skp authored Sep 9, 2024
2 parents ce27722 + 5c74619 commit bc3e9e0
Show file tree
Hide file tree
Showing 51 changed files with 625 additions and 478 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.ltk.core.refactoring
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.ltk.core.refactoring; singleton:=true
Bundle-Version: 3.14.500.qualifier
Bundle-Version: 3.14.600.qualifier
Bundle-Activator: org.eclipse.ltk.internal.core.refactoring.RefactoringCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public final long getTimeStamp() {
public final int hashCode() {
int code= getDescription().hashCode();
if (fTimeStamp >= 0)
code+= (17 * fTimeStamp);
code+= 17 * Long.hashCode(fTimeStamp);
return code;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public final int hashCode() {
int code= getDescription().hashCode();
final long stamp= getTimeStamp();
if (stamp >= 0)
code+= (17 * stamp);
code+= 17 * Long.hashCode(stamp);
return code;
}

Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.search.core/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.search.core;singleton:=true
Bundle-Version: 3.16.300.qualifier
Bundle-Version: 3.16.400.qualifier
Bundle-Activator: org.eclipse.search.internal.core.SearchCorePlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
import org.eclipse.core.runtime.jobs.Job;
Expand Down Expand Up @@ -205,8 +204,13 @@ public IStatus processFile(List<IFile> sameFiles, IProgressMonitor monitor) {
occurences = locateMatches(file, charsequence, matcher, monitor);
} else {
try {
boolean reportTextOnly = !fCollector.reportBinaryFile(file);
if (reportTextOnly && hasBinaryContentType(file)) {
// fail fast for binary file types without opening the file
return Status.OK_STATUS;
}
charsequence = fileCharSequenceProvider.newCharSequence(file);
if (hasBinaryContent(charsequence, file) && !fCollector.reportBinaryFile(file)) {
if (reportTextOnly && hasBinaryContent(charsequence)) {
return Status.OK_STATUS;
}
occurences = locateMatches(file, charsequence, matcher, monitor);
Expand Down Expand Up @@ -435,21 +439,25 @@ public IStatus search(TextSearchScope scope, IProgressMonitor monitor) {
return search(scope.evaluateFilesInScope(fStatus), monitor);
}

private boolean hasBinaryContent(CharSequence seq, IFile file) throws CoreException {
if (seq instanceof String) {
if (!((String) seq).contains("\0")) { //$NON-NLS-1$
// fail fast to avoid file.getContentDescription():
return false;
private final IContentType TEXT_TYPE = Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);

private boolean hasBinaryContentType(IFile file) {
IContentType[] contentTypes = Platform.getContentTypeManager().findContentTypesFor(file.getName());
for (IContentType contentType : contentTypes) {
if (contentType.isKindOf(TEXT_TYPE)) {
return false; // is text
}
}
IContentDescription desc= file.getContentDescription();
if (desc != null) {
IContentType contentType= desc.getContentType();
if (contentType != null && contentType.isKindOf(Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT))) {
return false;
}
if (contentTypes.length > 0) {
return true; // has some not text type
}
return false; // unknown
}

private boolean hasBinaryContent(CharSequence seq) {
if (seq instanceof String s) {
return (s.contains("\0")); //$NON-NLS-1$
}
// avoid calling seq.length() at it runs through the complete file,
// thus it would do so for all binary files.
try {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.forms/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: %name
Bundle-SymbolicName: org.eclipse.ui.forms;singleton:=true
Bundle-Version: 3.13.300.qualifier
Bundle-Version: 3.13.400.qualifier
Bundle-Vendor: %provider-name
Bundle-Localization: plugin
Export-Package: org.eclipse.ui.forms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void layout(GC gc, int width, Locator loc, int lineHeight,
computeRowHeights(gc, width, loc, lineHeight, resourceTable);
for (ParagraphSegment segment : segments) {
boolean doSelect = false;
if (selectedLink != null && segment.equals(selectedLink))
if (selectedLink instanceof ParagraphSegment sl && segment.equals(sl))
doSelect = true;
segment.layout(gc, width, loc, resourceTable, doSelect);
}
Expand All @@ -182,7 +182,7 @@ public void paint(GC gc, Rectangle repaintRegion,
if (!segment.intersects(repaintRegion))
continue;
boolean doSelect = false;
if (selectedLink != null && segment.equals(selectedLink))
if (selectedLink instanceof ParagraphSegment sl && segment.equals(sl))
doSelect = true;
segment.paint(gc, false, resourceTable, doSelect, selData, repaintRegion);
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.ide/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: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.ide; singleton:=true
Bundle-Version: 3.22.300.qualifier
Bundle-Version: 3.22.400.qualifier
Bundle-Activator: org.eclipse.ui.internal.ide.IDEWorkbenchPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Plugin.providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package org.eclipse.ui.actions;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.net.URI;
Expand Down Expand Up @@ -528,7 +530,11 @@ private void copyExisting(IResource source, IResource existing, IProgressMonitor
IFile sourceFile = getFile(source);

if (sourceFile != null) {
existingFile.setContents(sourceFile.getContents(), IResource.KEEP_HISTORY, subMonitor.split(1));
try (InputStream contents = sourceFile.getContents()) {
existingFile.setContents(contents, IResource.KEEP_HISTORY, subMonitor.split(1));
} catch (IOException closeException) {
// never happens
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
*******************************************************************************/
package org.eclipse.ui.actions;

import java.io.IOException;
import java.io.InputStream;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
Expand Down Expand Up @@ -199,7 +202,11 @@ private void moveExisting(IResource source, IResource existing, IProgressMonitor
IFile sourceFile = getFile(source);

if (sourceFile != null) {
existingFile.setContents(sourceFile.getContents(), IResource.KEEP_HISTORY, subMonitor.split(1));
try (InputStream contents = sourceFile.getContents()) {
existingFile.setContents(contents, IResource.KEEP_HISTORY, subMonitor.split(1));
} catch (IOException closeException) {
// never happens
}
delete(sourceFile, subMonitor.split(1));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*******************************************************************************/
package org.eclipse.ui.ide.undo;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -760,7 +762,12 @@ private static IResourceSnapshot<IResource> copyOverExistingResource(
// restored.
IResourceSnapshot<IResource> fileDescription = ResourceSnapshotFactory.fromResource(existingFile);
// Reset the contents to that of the file being moved
existingFile.setContents(file.getContents(), IResource.KEEP_HISTORY, subMonitor.split(1));
try (InputStream contents = file.getContents()) {
existingFile.setContents(contents, IResource.KEEP_HISTORY, subMonitor.split(1));
} catch (IOException closeException) {
// never happens
}

fileDescription.recordStateFromHistory(subMonitor.split(1));
// Now delete the source file if requested
// We don't need to remember anything about it, because
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,33 +474,38 @@ protected String getUnexpectedPathHint() {
}
String normalisedPath = path.normalize().toString();
String normalisedPathWithSeperator = normalisedPath + File.separator;
if (!isWritable(path)) {
return NLS.bind(IDEWorkbenchMessages.ChooseWorkspaceDialog_NotWriteablePathWarning, normalisedPath);
}
if (normalisedPathWithSeperator.contains(TILDE)) {
return NLS.bind(IDEWorkbenchMessages.ChooseWorkspaceDialog_TildeNonExpandedWarning, normalisedPath);
}
if (!workspaceLocation.equalsIgnoreCase(normalisedPath)
&& !workspaceLocation.equalsIgnoreCase(normalisedPathWithSeperator)) {
return NLS.bind(IDEWorkbenchMessages.ChooseWorkspaceDialog_ResolvedAbsolutePath, normalisedPath);
}
if (!maybeWritable(path)) {
return NLS.bind(IDEWorkbenchMessages.ChooseWorkspaceDialog_NotWriteablePathWarning, normalisedPath);
}
}
return ""; //$NON-NLS-1$
}

/**
* @param path
* @return
*/
private boolean isWritable(Path path) {
if (Files.exists(path)) {
return Files.isWritable(path);
}
Path parent = path.getParent();
if (parent != null) {
return isWritable(parent);
/** the returned value may be wrong **/
private boolean maybeWritable(Path path) {
try {
if (Files.exists(path)) {
// both java.io.File.canWrite() and
// java.nio.file.Files.isWritable(Path)
// can not be trusted on windows. they may return wrong values.
// for example JDK-8282720, JDK-8148211, JDK-8154915
return Files.isWritable(path);
}
Path parent = path.getParent();
if (parent == null) {
return false;
}
return maybeWritable(parent);
} catch (SecurityException se) {
return false;
}
return true;
}

protected Composite createBrowseComposite(Composite parent) {
Expand Down Expand Up @@ -545,7 +550,8 @@ protected Combo createPathCombo(Composite panel) {
*/
private boolean isValidPath(String path) {
try {
return isWritable(new File(path).toPath());
Path.of(path);
return true;
} catch (InvalidPathException e) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2772,8 +2772,8 @@ public void widgetSelected(SelectionEvent e) {
setupDescriptionText(null);
}

private String[] timeIntervalPrefixes = {"s", "m", "h", "d"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
private double[] timeIntervalScale = {60, 60, 24};
private static final String[] TIME_INTERVAL_PREFIXES = { "s", "m", "h", "d" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
private static final long[] TIME_INTERVAL_SCALE = { 60, 60, 24 };

private String convertToEditableTimeInterval(String string) {
if (string.isEmpty())
Expand All @@ -2786,22 +2786,22 @@ private String convertToEditableTimeInterval(String string) {
}
if (value == 0)
return Long.toString(0);
for (int i = 0; i < timeIntervalPrefixes.length - 1; i++) {
if (value % timeIntervalScale[i] != 0)
return Long.toString(value) + timeIntervalPrefixes[i];
value /= timeIntervalScale[i];
for (int i = 0; i < TIME_INTERVAL_PREFIXES.length - 1; i++) {
if (value % TIME_INTERVAL_SCALE[i] != 0)
return Long.toString(value) + TIME_INTERVAL_PREFIXES[i];
value /= TIME_INTERVAL_SCALE[i];
}
return Long.toString(value) + timeIntervalPrefixes[timeIntervalPrefixes.length - 1];
return Long.toString(value) + TIME_INTERVAL_PREFIXES[TIME_INTERVAL_PREFIXES.length - 1];
}

private String convertFromEditableTimeInterval(String string) {
if (string.isEmpty())
return string;
for (int i = 1; i < timeIntervalPrefixes.length; i++) {
if (string.endsWith(timeIntervalPrefixes[i])) {
for (int i = 1; i < TIME_INTERVAL_PREFIXES.length; i++) {
if (string.endsWith(TIME_INTERVAL_PREFIXES[i])) {
long value = Long.parseLong(string.substring(0, string.length() - 1));
for (int j = 0; j < i; j++)
value *= timeIntervalScale[j];
value *= TIME_INTERVAL_SCALE[j];
return Long.toString(value);
}
}
Expand All @@ -2810,7 +2810,7 @@ private String convertFromEditableTimeInterval(String string) {
}


private String[] lengthPrefixes = { "", "k", "m", "g" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
private static final String[] METRIC_PREFIXES = { "", "k", "m", "g" }; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$

// converts "32768" to "32k"
private String convertToEditableLength(String string) {
Expand All @@ -2824,23 +2824,23 @@ private String convertToEditableLength(String string) {
}
if (value == 0)
return Long.toString(0);
for (int i = 0; i < lengthPrefixes.length; i++) {
for (int i = 0; i < METRIC_PREFIXES.length; i++) {
if (value % 1024 != 0)
return Long.toString(value) + lengthPrefixes[i];
if ((i + 1) < lengthPrefixes.length)
return Long.toString(value) + METRIC_PREFIXES[i];
if ((i + 1) < METRIC_PREFIXES.length)
value /= 1024;
}
return Long.toString(value) + lengthPrefixes[lengthPrefixes.length - 1];
return Long.toString(value) + METRIC_PREFIXES[METRIC_PREFIXES.length - 1];
}

// converts "32k" to "32768"
private String convertFromEditableLength(String string) throws NumberFormatException {
if (string.isEmpty())
return string;
for (int i = 1; i < lengthPrefixes.length; i++) {
if (string.endsWith(lengthPrefixes[i])) {
for (int i = 1; i < METRIC_PREFIXES.length; i++) {
if (string.endsWith(METRIC_PREFIXES[i])) {
long value = Long.parseLong(string.substring(0, string.length() - 1));
value *= Math.pow(1024, i);
value *= 2 << (10 * i - 1);
return Long.toString(value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ ChooseWorkspaceDialog_recentWorkspaces=&Recent Workspaces
ChooseWorkspaceDialog_ResolvedAbsolutePath=Full path: {0}
ChooseWorkspaceDialog_TildeNonExpandedWarning=\u26A0\uFE0F '~' is not expanded, full path: {0}
ChooseWorkspaceDialog_InvalidPathWarning=\u26A0\uFE0F The path is invalid on this system: {0}
ChooseWorkspaceDialog_NotWriteablePathWarning=\u26A0\uFE0F The path is not writable by the current user: {0}
ChooseWorkspaceDialog_NotWriteablePathWarning=\u26A0\uFE0F The path may not be writable by the current user: {0}
ChooseWorkspaceDialog_useDefaultMessage=&Use this as the default and do not ask again

ChooseWorkspaceWithSettingsDialog_SettingsGroupName=&Copy Settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ public static boolean isZipFile(String fileName) {
*/
@SuppressWarnings("resource")
public static void closeStructureProvider(ILeveledImportStructureProvider structureProvider, Shell shell) {
if (structureProvider instanceof ZipLeveledStructureProvider) {
closeZipFile(((ZipLeveledStructureProvider) structureProvider).getZipFile(), shell);
if (structureProvider instanceof ZipLeveledStructureProvider zsp) {
closeZipFile(zsp.getZipFile(), shell);
}
if (structureProvider instanceof TarLeveledStructureProvider) {
closeTarFile(((TarLeveledStructureProvider) structureProvider).getTarFile(), shell);
if (structureProvider instanceof TarLeveledStructureProvider tsp) {
closeTarFile(tsp.getTarFile(), shell);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public class TarFile implements AutoCloseable {
private final File file;
private TarInputStream entryEnumerationStream;
private final TarInputStream entryEnumerationStream;
private TarEntry curEntry;
private TarInputStream entryStream;

Expand All @@ -52,6 +52,9 @@ public TarFile(File file) throws TarException, IOException {
//If it is not compressed we close
//the old one and recreate
in.close();
in = null;
}
if (in == null) {
in = new FileInputStream(file);
}
try {
Expand Down
Loading

0 comments on commit bc3e9e0

Please sign in to comment.