Commit 282d5446 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 4.8

parent 6bad8838
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>eclipse.platform.text</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
......@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.core.filebuffers.tests;singleton:=true
Bundle-Version: 3.11.100.qualifier
Bundle-Version: 3.11.200.qualifier
Bundle-Activator: org.eclipse.core.filebuffers.tests.FileBuffersTestPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %Plugin.providerName
......@@ -17,3 +17,4 @@ Require-Bundle:
org.junit;bundle-version="4.12.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Automatic-Module-Name: org.eclipse.core.filebuffers.tests
......@@ -14,12 +14,12 @@
<parent>
<artifactId>tests-pom</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.7.3-SNAPSHOT</version>
<version>4.8.0-SNAPSHOT</version>
<relativePath>../tests-pom/</relativePath>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.filebuffers.tests</artifactId>
<version>3.11.100-SNAPSHOT</version>
<version>3.11.200-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
......
......@@ -69,12 +69,12 @@ public class FileBufferCreation {
private IPath createLinkedFile(String linkedFileName, String linkedFileTarget) throws CoreException {
IFile linkedFile= ResourceHelper.createLinkedFile(fProject, new Path(linkedFileName), FileBuffersTestPlugin.getDefault(), new Path(linkedFileTarget));
return linkedFile != null ? linkedFile.getFullPath() : null;
return linkedFile.getFullPath();
}
private IPath createLinkedFolder(String linkedFolderName, String linkedFolderTarget) throws CoreException {
IFolder linkedFolder= ResourceHelper.createLinkedFolder(fProject, new Path(linkedFolderName), FileBuffersTestPlugin.getDefault(), new Path(linkedFolderTarget));
return linkedFolder != null ? linkedFolder.getFullPath() : null;
return linkedFolder.getFullPath();
}
/*
......
......@@ -862,7 +862,7 @@ public abstract class FileBufferFunctions {
IPath newLocation= moveUnderlyingFile();
if (newLocation != null) {
if (listener.count != 1 || listener.buffer != fileBuffer || !newLocation.equals(listener.newLocation)) {
StringBuffer buf= new StringBuffer();
StringBuilder buf= new StringBuilder();
buf.append("Wrong listener notifcation in " + getClass().getName() + ":\n");
buf.append("listener.count: " + listener.count + " (expected: 1)\n");
if (newLocation.equals(listener.newLocation))
......
......@@ -14,6 +14,8 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import org.junit.After;
import org.junit.Test;
......@@ -68,7 +70,11 @@ public class FileBuffersForNonExistingWorkspaceFiles extends FileBufferFunctions
@Test
public void testBug118199_fixed() throws Exception {
IFile file= getProject().getWorkspace().getRoot().getFileForLocation(getPath());
IPath location= getPath();
IFile file= getProject().getWorkspace().getRoot().getFileForLocation(location);
if (file == null) {
throw new IOException("File '" + location + "' can not be found."); //$NON-NLS-1$ //$NON-NLS-2$
}
IPath path= file.getFullPath();
assertFalse(file.exists());
fManager.connect(path, LocationKind.IFILE, null);
......
......@@ -12,6 +12,8 @@ package org.eclipse.core.filebuffers.tests;
import static org.junit.Assert.*;
import java.io.IOException;
import org.junit.After;
import org.junit.Test;
......@@ -66,7 +68,11 @@ public class FileStoreFileBuffersForNonExistingWorkspaceFiles extends FileStoreF
@Test
public void testBug118199_fixed() throws Exception {
IFile file= getProject().getWorkspace().getRoot().getFileForLocation(getPath());
IPath location= getPath();
IFile file= getProject().getWorkspace().getRoot().getFileForLocation(location);
if (file == null) {
throw new IOException("File '" + location + "' can not be found."); //$NON-NLS-1$ //$NON-NLS-2$
}
IPath path= file.getFullPath();
assertFalse(file.exists());
fManager.connect(path, LocationKind.IFILE, null);
......
......@@ -64,25 +64,8 @@ public class FileTool {
String entryName = entry.getName();
File file = new File(dstDir, changeSeparator(entryName, '/', File.separatorChar));
file.getParentFile().mkdirs();
InputStream src = null;
OutputStream dst = null;
try {
src = zipFile.getInputStream(entry);
dst = new FileOutputStream(file);
try (InputStream src= zipFile.getInputStream(entry); OutputStream dst= new FileOutputStream(file)) {
transferData(src, dst);
} finally {
if(dst != null){
try {
dst.close();
} catch(IOException e){
}
}
if(src != null){
try {
src.close();
} catch(IOException e){
}
}
}
}
} finally {
......@@ -162,6 +145,9 @@ public class FileTool {
public static void copy(File src, File dst) throws IOException {
if(src.isDirectory()){
String[] srcChildren = src.list();
if (srcChildren == null) {
throw new IOException("Content from directory '" + src.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
}
for(int i = 0; i < srcChildren.length; ++i){
File srcChild= new File(src, srcChildren[i]);
File dstChild= new File(dst, srcChildren[i]);
......
......@@ -58,7 +58,7 @@ public class MockDocumentSetupParticipants {
@Override
public void setup(IDocument document, IPath location, LocationKind locationKind) {
if (locationKind == LocationKind.IFILE)
append(document, new StringBuffer(location.toPortableString()).reverse().toString());
append(document, new StringBuilder(location.toPortableString()).reverse().toString());
}
}
......@@ -66,7 +66,7 @@ public class MockDocumentSetupParticipants {
@Override
public void setup(IDocument document, IPath location, LocationKind locationKind) {
if (locationKind == LocationKind.LOCATION)
append(document, new StringBuffer(location.toPortableString()).reverse().toString());
append(document, new StringBuilder(location.toPortableString()).reverse().toString());
}
}
......@@ -74,7 +74,7 @@ public class MockDocumentSetupParticipants {
@Override
public void setup(IDocument document, IPath location, LocationKind locationKind) {
if (locationKind == LocationKind.NORMALIZE)
append(document, new StringBuffer(location.toPortableString()).reverse().toString());
append(document, new StringBuilder(location.toPortableString()).reverse().toString());
}
}
......
......@@ -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.6.100.qualifier
Bundle-Version: 3.6.200.qualifier
Bundle-Activator: org.eclipse.core.internal.filebuffers.FileBuffersPlugin
Bundle-ActivationPolicy: lazy
Bundle-Vendor: %providerName
......@@ -18,3 +18,4 @@ Require-Bundle:
org.eclipse.core.filesystem;bundle-version="[1.2.0,2.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.ibm.icu.text
Automatic-Module-Name: org.eclipse.core.filebuffers
Bug 534597 - Unanticipated comparator errors in I20180511-2000
\ No newline at end of file
......@@ -14,10 +14,10 @@
<parent>
<artifactId>eclipse.platform.text</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.7.3-SNAPSHOT</version>
<version>4.8.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.filebuffers</artifactId>
<version>3.6.100-SNAPSHOT</version>
<version>3.6.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
......@@ -532,7 +532,7 @@ public class FileStoreTextFileBuffer extends FileStoreFileBuffer implements ITex
}
in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
StringBuilder buffer= new StringBuilder(BUFFER_SIZE);
char[] readBuffer= new char[READER_CHUNK_SIZE];
int n= in.read(readBuffer);
while (n > 0) {
......
......@@ -521,7 +521,7 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
}
in= new BufferedReader(new InputStreamReader(contentStream, encoding), BUFFER_SIZE);
StringBuffer buffer= new StringBuffer(BUFFER_SIZE);
StringBuilder buffer= new StringBuilder(BUFFER_SIZE);
char[] readBuffer= new char[READER_CHUNK_SIZE];
int n= in.read(readBuffer);
while (n > 0) {
......
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
/bin/
/target/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.jface.text.examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
pluginProject.extensions=false
resolve.requirebundle=false
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CodeMinig Examples
Bundle-SymbolicName: org.eclipse.jface.text.examples
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.jface.text,
org.eclipse.core.runtime,
org.eclipse.swt,
org.eclipse.jface;bundle-version="3.14.0"
Automatic-Module-Name: org.eclipse.jface.text.examples
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2012, 2014 Eclipse Foundation and others.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Distribution License v1.0
which accompanies this distribution, and is available at
http://www.eclipse.org/org/documents/edl-v10.php
Contributors:
Igor Fedorenko - initial implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>eclipse.platform.text</artifactId>
<groupId>eclipse.platform.text</groupId>
<version>4.8.0-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.jface.text.examples</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
/**
* Copyright (c) 2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - [CodeMining] Add CodeMining support in SourceViewer - Bug 527515
*/
package org.eclipse.jface.text.examples.codemining;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.codemining.ICodeMiningProvider;
import org.eclipse.jface.text.codemining.LineHeaderCodeMining;
/**
* Abstract class for class name mining.
*
*/
public abstract class AbstractClassCodeMining extends LineHeaderCodeMining {
private final String className;
public AbstractClassCodeMining(String className, int afterLineNumber, IDocument document,
ICodeMiningProvider resolver) throws BadLocationException {
super(afterLineNumber, document, resolver);
this.className = className;
}
public String getClassName() {
return className;
}
public static String getLineText(IDocument document, int line) {
try {
int lo = document.getLineOffset(line);
int ll = document.getLineLength(line);
return document.get(lo, ll);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
/**
* Copyright (c) 2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - [CodeMining] Add CodeMining support in SourceViewer - Bug 527515
*/
package org.eclipse.jface.text.examples.codemining;
import java.util.concurrent.CompletableFuture;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.codemining.ICodeMiningProvider;
/**
* Class implementation mining.
*
*/
public class ClassImplementationCodeMining extends AbstractClassCodeMining {
public ClassImplementationCodeMining(String className, int afterLineNumber, IDocument document,
ICodeMiningProvider provider) throws BadLocationException {
super(className, afterLineNumber, document, provider);
}
@Override
protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor monitor) {
return CompletableFuture.runAsync(() -> {
IDocument document = viewer.getDocument();
String className = super.getClassName();
int refCount = 0;
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
// check if request was canceled.
monitor.isCanceled();
String line = getLineText(document, i);
refCount += line.contains("implements " + className) ? 1 : 0;
}
super.setLabel(refCount + " implementation");
});
}
}
/**
* Copyright (c) 2017 Angelo ZERR.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Angelo Zerr <angelo.zerr@gmail.com> - [CodeMining] Add CodeMining support in SourceViewer - Bug 527515
*/
package org.eclipse.jface.text.examples.codemining;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.codemining.AbstractCodeMiningProvider;
import org.eclipse.jface.text.codemining.ICodeMining;
/**
* Class implementation mining provider.
*
*/
public class ClassImplementationsCodeMiningProvider extends AbstractCodeMiningProvider {
@Override
public CompletableFuture<List<? extends ICodeMining>> provideCodeMinings(ITextViewer viewer,
IProgressMonitor monitor) {
return CompletableFuture.supplyAsync(() -> {
IDocument document = viewer.getDocument();
List<ICodeMining> lenses = new ArrayList<>();
int lineCount = document.getNumberOfLines();
for (int i = 0; i < lineCount; i++) {
// check if request was canceled.
monitor.isCanceled();
updateContentMining(i, document, "class ", lenses);
updateContentMining(i, document, "interface ", lenses);
}
return lenses;
});
}
private void updateContentMining(int lineIndex, IDocument document, String token, List<ICodeMining> lenses) {
String line = AbstractClassCodeMining.getLineText(document, lineIndex).trim();
int index = line.indexOf(token);
if (index == 0) {
String className = line.substring(index + token.length(), line.length());
index = className.indexOf(" ");