Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-11-30 19:23:22 +0000
committerMarkus Keller2015-12-01 12:59:16 +0000
commit96da92a20589d62dad534245c5d9c4d45618ee95 (patch)
treedb7f27dc0839db136db463ad28a7e763a6a07a91 /org.eclipse.core.filebuffers
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
Diffstat (limited to 'org.eclipse.core.filebuffers')
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java14
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java15
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java97
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java6
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java8
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java68
6 files changed, 105 insertions, 103 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
index 2092ae679..b141a8849 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/GenericFileBufferOperationRunner.java
@@ -200,21 +200,21 @@ public class GenericFileBufferOperationRunner {
}
private IFileBuffer[] findUnsynchronizedFileBuffers(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (!fileBuffers[i].isSynchronizationContextRequested())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private IFileBuffer[] findSynchronizedFileBuffers(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (fileBuffers[i].isSynchronizationContextRequested())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private IFileBuffer[] createFileBuffers(IPath[] locations, IProgressMonitor progressMonitor) throws CoreException {
@@ -255,13 +255,13 @@ public class GenericFileBufferOperationRunner {
}
private IFileBuffer[] findFileBuffersToSave(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IFileBuffer buffer= fileBuffers[i];
if (!buffer.isDirty())
list.add(buffer);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private boolean isCommitable(IFileBuffer[] fileBuffers) {
@@ -273,7 +273,7 @@ public class GenericFileBufferOperationRunner {
}
protected ISchedulingRule computeCommitRule(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<ISchedulingRule> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
ISchedulingRule rule= fileBuffers[i].computeCommitRule();
if (rule != null)
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
index c4321198b..37e96d2ad 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/TextFileBufferOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* 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
@@ -33,6 +33,7 @@ import org.eclipse.jface.text.DocumentRewriteSession;
import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension4;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextUtilities;
/**
@@ -96,7 +97,7 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
MultiTextEditWithProgress edit= computeTextEdit(textFileBuffer, subMonitor);
subMonitor.done();
if (edit != null) {
- Object stateData= startRewriteSession(textFileBuffer);
+ Map<String, IDocumentPartitioner> stateData= startRewriteSession(textFileBuffer);
try {
subMonitor= Progress.getSubMonitor(progressMonitor, 90);
applyTextEdit(textFileBuffer, edit, subMonitor);
@@ -111,8 +112,8 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
}
}
- private Object startRewriteSession(ITextFileBuffer fileBuffer) {
- Object stateData= null;
+ private Map<String, IDocumentPartitioner> startRewriteSession(ITextFileBuffer fileBuffer) {
+ Map<String, IDocumentPartitioner> stateData= null;
IDocument document= fileBuffer.getDocument();
if (document instanceof IDocumentExtension4) {
@@ -124,14 +125,14 @@ public abstract class TextFileBufferOperation implements IFileBufferOperation {
return stateData;
}
- private void stopRewriteSession(ITextFileBuffer fileBuffer, Object stateData) {
+ private void stopRewriteSession(ITextFileBuffer fileBuffer, Map<String, IDocumentPartitioner> stateData) {
IDocument document= fileBuffer.getDocument();
if (document instanceof IDocumentExtension4) {
IDocumentExtension4 extension= (IDocumentExtension4) document;
extension.stopRewriteSession(fDocumentRewriteSession);
fDocumentRewriteSession= null;
- } else if (stateData instanceof Map)
- TextUtilities.addDocumentPartitioners(document, (Map) stateData);
+ } else if (stateData != null)
+ TextUtilities.addDocumentPartitioners(document, stateData);
}
private void applyTextEdit(ITextFileBuffer fileBuffer, MultiTextEditWithProgress textEdit, IProgressMonitor progressMonitor) throws CoreException, OperationCanceledException {
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
index 63731ff3a..4e5e483f6 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* 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
@@ -85,17 +85,17 @@ public class ExtensionsRegistry {
protected static final String WILDCARD= "*"; //$NON-NLS-1$
/** The mapping between file attributes and configuration elements describing document factories. */
- private Map fFactoryDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fFactoryDescriptors= new HashMap<>();
/** The mapping between configuration elements for document factories and instantiated document factories. */
- private Map fFactories= new HashMap();
+ private Map<IConfigurationElement, Object> fFactories= new HashMap<>();
/** The mapping between file attributes and configuration elements describing document setup participants. */
- private Map fSetupParticipantDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fSetupParticipantDescriptors= new HashMap<>();
/** The mapping between configuration elements for setup participants and instantiated setup participants. */
- private Map fSetupParticipants= new HashMap();
+ private Map<IConfigurationElement, Object> fSetupParticipants= new HashMap<>();
/** The mapping between file attributes and configuration elements describing annotation model factories. */
- private Map fAnnotationModelFactoryDescriptors= new HashMap();
+ private Map<Object, Set<IConfigurationElement>> fAnnotationModelFactoryDescriptors= new HashMap<>();
/** The mapping between configuration elements for annotation model factories */
- private Map fAnnotationModelFactories= new HashMap();
+ private Map<IConfigurationElement, Object> fAnnotationModelFactories= new HashMap<>();
/** The content type manager. */
protected IContentTypeManager fContentTypeManager= Platform.getContentTypeManager();
@@ -125,16 +125,16 @@ public class ExtensionsRegistry {
* @param element the configuration element
* @param map the map which remembers the configuration element
*/
- private void read(String attributeName, IConfigurationElement element, Map map) {
+ private void read(String attributeName, IConfigurationElement element, Map<Object, Set<IConfigurationElement>> map) {
String value= element.getAttribute(attributeName);
if (value != null) {
StringTokenizer tokenizer= new StringTokenizer(value, ","); //$NON-NLS-1$
while (tokenizer.hasMoreTokens()) {
String token= tokenizer.nextToken().trim();
- Set s= (Set) map.get(token);
+ Set<IConfigurationElement> s= map.get(token);
if (s == null) {
- s= new HashSet();
+ s= new HashSet<>();
map.put(token, s);
}
s.add(element);
@@ -150,7 +150,7 @@ public class ExtensionsRegistry {
* @param element the configuration element
* @param map the map which remembers the configuration element
*/
- private void readContentType(String attributeName, IConfigurationElement element, Map map) {
+ private void readContentType(String attributeName, IConfigurationElement element, Map<Object, Set<IConfigurationElement>> map) {
String value= element.getAttribute(attributeName);
if (value != null) {
IContentType contentType= fContentTypeManager.getContentType(value);
@@ -159,9 +159,9 @@ public class ExtensionsRegistry {
return;
}
ContentTypeAdapter adapter= new ContentTypeAdapter(contentType);
- Set s= (Set) map.get(adapter);
+ Set<IConfigurationElement> s= map.get(adapter);
if (s == null) {
- s= new HashSet();
+ s= new HashSet<>();
map.put(adapter, s);
}
s.add(element);
@@ -187,7 +187,7 @@ public class ExtensionsRegistry {
* @param isContentTypeId the child element is a content type id
* @param descriptors the map to be filled
*/
- private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map descriptors) {
+ private void initialize(String extensionPointName, String childElementName, boolean isContentTypeId, Map<Object, Set<IConfigurationElement>> descriptors) {
IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(FileBuffersPlugin.PLUGIN_ID, extensionPointName);
if (extensionPoint == null) {
@@ -214,13 +214,14 @@ public class ExtensionsRegistry {
* @param extensionType the requested result type
* @return the executable extension for the given configuration element.
*/
- private Object getExtension(IConfigurationElement entry, Map extensions, Class extensionType) {
- Object extension= extensions.get(entry);
+ @SuppressWarnings("unchecked")
+ private <T> T getExtension(IConfigurationElement entry, Map<IConfigurationElement, Object> extensions, Class<T> extensionType) {
+ T extension= (T) extensions.get(entry);
if (extension != null)
return extension;
try {
- extension= entry.createExecutableExtension("class"); //$NON-NLS-1$
+ extension= (T) entry.createExecutableExtension("class"); //$NON-NLS-1$
} catch (CoreException x) {
log(x.getStatus());
}
@@ -239,10 +240,10 @@ public class ExtensionsRegistry {
* @param set the set from which to choose
* @return the selected configuration element
*/
- private IConfigurationElement selectConfigurationElement(Set set) {
+ private IConfigurationElement selectConfigurationElement(Set<IConfigurationElement> set) {
if (set != null && !set.isEmpty()) {
- Iterator e= set.iterator();
- return (IConfigurationElement) e.next();
+ Iterator<IConfigurationElement> e= set.iterator();
+ return e.next();
}
return null;
}
@@ -256,10 +257,10 @@ public class ExtensionsRegistry {
*/
@Deprecated
protected org.eclipse.core.filebuffers.IDocumentFactory getDocumentFactory(String nameOrExtension) {
- Set set= (Set) fFactoryDescriptors.get(nameOrExtension);
+ Set<IConfigurationElement> set= fFactoryDescriptors.get(nameOrExtension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (org.eclipse.core.filebuffers.IDocumentFactory)getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
+ return getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
}
return null;
}
@@ -273,15 +274,15 @@ public class ExtensionsRegistry {
*/
@Deprecated
protected org.eclipse.core.filebuffers.IDocumentFactory doGetDocumentFactory(IContentType[] contentTypes) {
- Set set= null;
+ Set<IConfigurationElement> set= null;
int i= 0;
while (i < contentTypes.length && set == null) {
- set= (Set) fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ set= fFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
}
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (org.eclipse.core.filebuffers.IDocumentFactory)getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
+ return getExtension(entry, fFactories, org.eclipse.core.filebuffers.IDocumentFactory.class);
}
return null;
}
@@ -312,16 +313,16 @@ public class ExtensionsRegistry {
* @param nameOrExtension the name or extension to be used for lookup
* @return the sharable set of document setup participants
*/
- protected List getDocumentSetupParticipants(String nameOrExtension) {
- Set set= (Set) fSetupParticipantDescriptors.get(nameOrExtension);
+ protected List<IDocumentSetupParticipant> getDocumentSetupParticipants(String nameOrExtension) {
+ Set<IConfigurationElement> set= fSetupParticipantDescriptors.get(nameOrExtension);
if (set == null)
return null;
- List participants= new ArrayList();
- Iterator e= set.iterator();
+ List<IDocumentSetupParticipant> participants= new ArrayList<>();
+ Iterator<IConfigurationElement> e= set.iterator();
while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
+ IConfigurationElement entry= e.next();
+ IDocumentSetupParticipant participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
@@ -335,20 +336,20 @@ public class ExtensionsRegistry {
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
- private List doGetDocumentSetupParticipants(IContentType[] contentTypes) {
- Set resultSet= new HashSet();
+ private List<IDocumentSetupParticipant> doGetDocumentSetupParticipants(IContentType[] contentTypes) {
+ Set<IConfigurationElement> resultSet= new HashSet<>();
int i= 0;
while (i < contentTypes.length) {
- Set set= (Set) fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ Set<IConfigurationElement> set= fSetupParticipantDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
if (set != null)
resultSet.addAll(set);
}
- List participants= new ArrayList();
- Iterator e= resultSet.iterator();
+ List<IDocumentSetupParticipant> participants= new ArrayList<>();
+ Iterator<IConfigurationElement> e= resultSet.iterator();
while (e.hasNext()) {
- IConfigurationElement entry= (IConfigurationElement) e.next();
- Object participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
+ IConfigurationElement entry= e.next();
+ IDocumentSetupParticipant participant= getExtension(entry, fSetupParticipants, IDocumentSetupParticipant.class);
if (participant != null)
participants.add(participant);
}
@@ -364,8 +365,8 @@ public class ExtensionsRegistry {
* @param contentTypes the contentTypes to be used for lookup
* @return the sharable set of document setup participants
*/
- protected List getDocumentSetupParticipants(IContentType[] contentTypes) {
- List participants= doGetDocumentSetupParticipants(contentTypes);
+ protected List<IDocumentSetupParticipant> getDocumentSetupParticipants(IContentType[] contentTypes) {
+ List<IDocumentSetupParticipant> participants= doGetDocumentSetupParticipants(contentTypes);
while (participants == null) {
contentTypes= computeBaseContentTypes(contentTypes);
if (contentTypes == null)
@@ -382,15 +383,15 @@ public class ExtensionsRegistry {
* @return the sharable annotation model factory or <code>null</code>
*/
private IAnnotationModelFactory doGetAnnotationModelFactory(IContentType[] contentTypes) {
- Set set= null;
+ Set<IConfigurationElement> set= null;
int i= 0;
while (i < contentTypes.length && set == null) {
- set= (Set) fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ set= fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
}
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ return getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
}
return null;
}
@@ -421,10 +422,10 @@ public class ExtensionsRegistry {
* @return the sharable document factory or <code>null</code>
*/
protected IAnnotationModelFactory getAnnotationModelFactory(String extension) {
- Set set= (Set) fAnnotationModelFactoryDescriptors.get(extension);
+ Set<IConfigurationElement> set= fAnnotationModelFactoryDescriptors.get(extension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
- return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ return getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
}
return null;
}
@@ -451,7 +452,7 @@ public class ExtensionsRegistry {
* @return the set of direct base content types
*/
private IContentType[] computeBaseContentTypes(IContentType[] contentTypes) {
- List baseTypes= new ArrayList();
+ List<IContentType> baseTypes= new ArrayList<>();
for (int i= 0; i < contentTypes.length; i++) {
IContentType baseType= contentTypes[i].getBaseType();
if (baseType != null)
@@ -497,9 +498,9 @@ public class ExtensionsRegistry {
* @since 3.3
*/
public IDocumentSetupParticipant[] getDocumentSetupParticipants(IPath location, LocationKind locationKind) {
- Set participants= new HashSet();
+ Set<IDocumentSetupParticipant> participants= new HashSet<>();
- List p= getDocumentSetupParticipants(findContentTypes(location, locationKind));
+ List<IDocumentSetupParticipant> p= getDocumentSetupParticipants(findContentTypes(location, locationKind));
if (p != null)
participants.addAll(p);
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
index 0c171b055..af4e33cca 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceExtensionRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* 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
@@ -116,9 +116,9 @@ public class ResourceExtensionRegistry extends ExtensionsRegistry {
* @return the sharable set of document setup participants
*/
IDocumentSetupParticipant[] getDocumentSetupParticipants(IFile file) {
- Set participants= new HashSet();
+ Set<IDocumentSetupParticipant> participants= new HashSet<>();
- List p= getDocumentSetupParticipants(findContentTypes(file));
+ List<IDocumentSetupParticipant> p= getDocumentSetupParticipants(findContentTypes(file));
if (p != null)
participants.addAll(p);
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
index d3932fdbe..0f183eb5c 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBufferManager.java
@@ -236,7 +236,7 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private IStatus validateEdit(IFileBuffer[] fileBuffers, Object computationContext) {
- ArrayList list= new ArrayList();
+ ArrayList<IFile> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IFile file= getWorkspaceFile(fileBuffers[i]);
if (file != null)
@@ -248,12 +248,12 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private IFileBuffer[] findFileBuffersToValidate(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IFileBuffer> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
if (!fileBuffers[i].isStateValidated())
list.add(fileBuffers[i]);
}
- return (IFileBuffer[]) list.toArray(new IFileBuffer[list.size()]);
+ return list.toArray(new IFileBuffer[list.size()]);
}
private void validationStateAboutToBeChanged(IFileBuffer[] fileBuffers) {
@@ -288,7 +288,7 @@ public class ResourceTextFileBufferManager extends TextFileBufferManager {
}
private ISchedulingRule computeValidateStateRule(IFileBuffer[] fileBuffers) {
- ArrayList list= new ArrayList();
+ ArrayList<IResource> list= new ArrayList<>();
for (int i= 0; i < fileBuffers.length; i++) {
IResource resource= getWorkspaceFile(fileBuffers[i]);
if (resource != null)
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
index 1a0da3fce..25aba768c 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
@@ -68,9 +68,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
protected static final IContentType TEXT_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(IContentTypeManager.CT_TEXT);
- private Map fFilesBuffers= new HashMap();
- private Map fFileStoreFileBuffers= new HashMap();
- private List fFileBufferListeners= new ArrayList();
+ private Map<IPath, AbstractFileBuffer> fFilesBuffers= new HashMap<>();
+ private Map<IFileStore, FileStoreFileBuffer> fFileStoreFileBuffers= new HashMap<>();
+ private List<IFileBufferListener> fFileBufferListeners= new ArrayList<>();
protected ExtensionsRegistry fRegistry;
private ISynchronizationContext fSynchronizationContext;
@@ -339,13 +339,13 @@ public class TextFileBufferManager implements ITextFileBufferManager {
private AbstractFileBuffer internalGetFileBuffer(IPath location) {
synchronized (fFilesBuffers) {
- return (AbstractFileBuffer)fFilesBuffers.get(location);
+ return fFilesBuffers.get(location);
}
}
private FileStoreFileBuffer internalGetFileBuffer(IFileStore fileStore) {
synchronized (fFileStoreFileBuffers) {
- return (FileStoreFileBuffer)fFileStoreFileBuffers.get(fileStore);
+ return fFileStoreFileBuffers.get(fileStore);
}
}
@@ -374,9 +374,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
@Override
public ITextFileBuffer getTextFileBuffer(IDocument document) {
Assert.isLegal(document != null);
- Iterator iter;
+ Iterator<AbstractFileBuffer> iter;
synchronized (fFilesBuffers) {
- iter= new ArrayList(fFilesBuffers.values()).iterator();
+ iter= new ArrayList<>(fFilesBuffers.values()).iterator();
}
while (iter.hasNext()) {
@@ -391,7 +391,7 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
}
synchronized (fFileStoreFileBuffers) {
- iter= new ArrayList(fFileStoreFileBuffers.values()).iterator();
+ iter= new ArrayList<AbstractFileBuffer>(fFileStoreFileBuffers.values()).iterator();
}
while (iter.hasNext()) {
Object buffer= iter.next();
@@ -409,16 +409,16 @@ public class TextFileBufferManager implements ITextFileBufferManager {
@Override
public IFileBuffer[] getFileBuffers() {
synchronized (fFilesBuffers) {
- Collection values= fFilesBuffers.values();
- return (IFileBuffer[])values.toArray(new IFileBuffer[values.size()]);
+ Collection<AbstractFileBuffer> values= fFilesBuffers.values();
+ return values.toArray(new IFileBuffer[values.size()]);
}
}
@Override
public IFileBuffer[] getFileStoreFileBuffers() {
synchronized (fFileStoreFileBuffers) {
- Collection values= fFileStoreFileBuffers.values();
- return (IFileBuffer[])values.toArray(new IFileBuffer[values.size()]);
+ Collection<FileStoreFileBuffer> values= fFileStoreFileBuffers.values();
+ return values.toArray(new IFileBuffer[values.size()]);
}
}
@@ -663,16 +663,16 @@ public class TextFileBufferManager implements ITextFileBufferManager {
// return createTextFileBuffer(location);
// }
- private Iterator getFileBufferListenerIterator() {
+ private Iterator<IFileBufferListener> getFileBufferListenerIterator() {
synchronized (fFileBufferListeners) {
- return new ArrayList(fFileBufferListeners).iterator();
+ return new ArrayList<>(fFileBufferListeners).iterator();
}
}
protected void fireDirtyStateChanged(final IFileBuffer buffer, final boolean isDirty) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -683,9 +683,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferContentAboutToBeReplaced(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -696,9 +696,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferContentReplaced(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -709,9 +709,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireUnderlyingFileMoved(final IFileBuffer buffer, final IPath target) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -722,9 +722,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireUnderlyingFileDeleted(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -735,9 +735,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateValidationChanged(final IFileBuffer buffer, final boolean isStateValidated) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -748,9 +748,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateChanging(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -761,9 +761,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireStateChangeFailed(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -774,9 +774,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferCreated(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {
@@ -787,9 +787,9 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
protected void fireBufferDisposed(final IFileBuffer buffer) {
- Iterator e= getFileBufferListenerIterator();
+ Iterator<IFileBufferListener> e= getFileBufferListenerIterator();
while (e.hasNext()) {
- final IFileBufferListener l= (IFileBufferListener) e.next();
+ final IFileBufferListener l= e.next();
SafeRunner.run(new SafeNotifier() {
@Override
public void run() {

Back to the top