Skip to main content
summaryrefslogtreecommitdiffstats
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.ui.workbench.texteditor
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.gz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.tar.xz
eclipse.platform.text-96da92a20589d62dad534245c5d9c4d45618ee95.zip
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java62
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java135
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java12
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java75
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java18
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java68
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java156
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java9
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java37
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java34
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java28
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java22
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java10
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java24
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java58
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java22
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.java18
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java20
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java6
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java72
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java17
40 files changed, 531 insertions, 515 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
index aa3552d62f7..a8db1336b85 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/HippieCompletionEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 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
@@ -148,10 +148,10 @@ public final class HippieCompletionEngine {
* @throws BadLocationException if there is some error scanning the
* document.
*/
- public List getCompletionsForward(IDocument document, CharSequence prefix,
+ public List<String> getCompletionsForward(IDocument document, CharSequence prefix,
int firstPosition, boolean currentWordLast) throws BadLocationException {
- ArrayList res= new ArrayList();
- for (Iterator it= getForwardIterator(document, prefix, firstPosition, currentWordLast); it.hasNext();) {
+ ArrayList<String> res= new ArrayList<>();
+ for (Iterator<String> it= getForwardIterator(document, prefix, firstPosition, currentWordLast); it.hasNext();) {
res.add(it.next());
}
return res;
@@ -170,9 +170,9 @@ public final class HippieCompletionEngine {
* The empty suggestion is not included in the results.
* @throws BadLocationException if any error occurs
*/
- public List getCompletionsBackwards(IDocument document, CharSequence prefix, int firstPosition) throws BadLocationException {
- ArrayList res= new ArrayList();
- for (Iterator it= getBackwardIterator(document, prefix, firstPosition); it.hasNext();) {
+ public List<String> getCompletionsBackwards(IDocument document, CharSequence prefix, int firstPosition) throws BadLocationException {
+ ArrayList<String> res= new ArrayList<>();
+ for (Iterator<String> it= getBackwardIterator(document, prefix, firstPosition); it.hasNext();) {
res.add(it.next());
}
return res;
@@ -210,12 +210,12 @@ public final class HippieCompletionEngine {
* @param suggestions a list of suggestions ({@link String}).
* @return a list of unique completion suggestions.
*/
- public List makeUnique(List suggestions) {
- HashSet seenAlready= new HashSet();
- ArrayList uniqueSuggestions= new ArrayList();
+ public List<String> makeUnique(List<String> suggestions) {
+ HashSet<String> seenAlready= new HashSet<>();
+ ArrayList<String> uniqueSuggestions= new ArrayList<>();
- for (Iterator i= suggestions.iterator(); i.hasNext();) {
- String suggestion= (String) i.next();
+ for (Iterator<String> i= suggestions.iterator(); i.hasNext();) {
+ String suggestion= i.next();
if (!seenAlready.contains(suggestion)) {
seenAlready.add(suggestion);
uniqueSuggestions.add(suggestion);
@@ -236,8 +236,8 @@ public final class HippieCompletionEngine {
* is always the current document.
* @since 3.6
*/
- public static List computeDocuments(ITextEditor currentTextEditor) {
- ArrayList documentsForSearch= new ArrayList();
+ public static List<IDocument> computeDocuments(ITextEditor currentTextEditor) {
+ ArrayList<IDocument> documentsForSearch= new ArrayList<>();
if (currentTextEditor == null) {
return documentsForSearch;
}
@@ -252,7 +252,7 @@ public final class HippieCompletionEngine {
return documentsForSearch;
}
- List computedDocuments= new ArrayList();
+ List<IDocument> computedDocuments= new ArrayList<>();
IWorkbenchWindow window= currentTextEditor.getSite().getWorkbenchWindow();
IEditorReference editorsArray[]= window.getActivePage().getEditorReferences();
@@ -295,7 +295,7 @@ public final class HippieCompletionEngine {
*
* @since 3.6
*/
- public Iterator getForwardIterator(IDocument document, CharSequence prefix, int firstPosition, boolean currentWordLast) {
+ public Iterator<String> getForwardIterator(IDocument document, CharSequence prefix, int firstPosition, boolean currentWordLast) {
return new HippieCompletionForwardIterator(document, prefix, firstPosition, currentWordLast);
}
@@ -312,7 +312,7 @@ public final class HippieCompletionEngine {
*
* @since 3.6
*/
- public Iterator getBackwardIterator(IDocument document, CharSequence prefix, int firstPosition) {
+ public Iterator<String> getBackwardIterator(IDocument document, CharSequence prefix, int firstPosition) {
return new HippieCompletionBackwardIterator(document, prefix, firstPosition);
}
@@ -331,7 +331,7 @@ public final class HippieCompletionEngine {
*
* @since 3.6
*/
- public Iterator getMultipleDocumentsIterator(IDocument document, List otherDocuments, CharSequence prefix, int firstPosition) {
+ public Iterator<String> getMultipleDocumentsIterator(IDocument document, List<IDocument> otherDocuments, CharSequence prefix, int firstPosition) {
return new MultipleDocumentsIterator(document, otherDocuments, prefix, firstPosition);
}
@@ -342,7 +342,7 @@ public final class HippieCompletionEngine {
*
* @since 3.6
*/
- private final class MultipleDocumentsIterator implements Iterator {
+ private final class MultipleDocumentsIterator implements Iterator<String> {
/**
* This is the next token to be returned (when null, no more tokens should be returned)
@@ -356,7 +356,7 @@ public final class HippieCompletionEngine {
private int fCurrLocation= -1;
/** These are the suggestions which we already loaded. */
- private final List fSuggestions;
+ private final List<String> fSuggestions;
/** This marks the current suggestion to be returned */
private int fCurrSuggestion= 0;
@@ -365,7 +365,7 @@ public final class HippieCompletionEngine {
private final CharSequence fPrefix;
/** The list of IDocuments that we should search */
- private final List fOtherDocuments;
+ private final List<IDocument> fOtherDocuments;
/**
* The document that's currently opened (that's the 1st we should look and we should 1st
@@ -380,15 +380,15 @@ public final class HippieCompletionEngine {
private boolean fAddedEmpty= false;
/** The 'current' forward iterator. */
- private Iterator fCompletionsForwardIterator;
+ private Iterator<String> fCompletionsForwardIterator;
/** The 'current' backward iterator. */
- private Iterator fCompletionsBackwardIterator;
+ private Iterator<String> fCompletionsBackwardIterator;
- private MultipleDocumentsIterator(IDocument openDocument, List otherDocuments,
+ private MultipleDocumentsIterator(IDocument openDocument, List<IDocument> otherDocuments,
CharSequence prefix, int selectionOffset) {
this.fPrefix= prefix;
- this.fSuggestions= new ArrayList();
+ this.fSuggestions= new ArrayList<>();
this.fOtherDocuments= otherDocuments;
this.fSelectionOffset= selectionOffset;
this.fOpenDocument= openDocument;
@@ -423,7 +423,7 @@ public final class HippieCompletionEngine {
while (fCurrLocation < this.fOtherDocuments.size()) {
fCompletionsForwardIterator= getForwardIterator(
- ((IDocument)this.fOtherDocuments.get(fCurrLocation)), fPrefix, 0, false);
+ (this.fOtherDocuments.get(fCurrLocation)), fPrefix, 0, false);
fCurrLocation++;
if (checkNext()) {
return;
@@ -458,7 +458,7 @@ public final class HippieCompletionEngine {
}
if (fSuggestions.size() > fCurrSuggestion) {
- fNext= (String)fSuggestions.get(fCurrSuggestion);
+ fNext= fSuggestions.get(fCurrSuggestion);
fCurrSuggestion++;
return true;
}
@@ -482,11 +482,11 @@ public final class HippieCompletionEngine {
* @return the next suggestion
*/
@Override
- public Object next() {
+ public String next() {
if (fNext == null) {
throw new NoSuchElementException("No more elements to iterate"); //$NON-NLS-1$
}
- Object ret= fNext;
+ String ret= fNext;
calculateNext();
return ret;
}
@@ -510,7 +510,7 @@ public final class HippieCompletionEngine {
*
* @since 3.6
*/
- private abstract class HippieCompletionIterator implements Iterator {
+ private abstract class HippieCompletionIterator implements Iterator<String> {
/** The document to be scanned */
protected IDocument fDocument;
@@ -578,7 +578,7 @@ public final class HippieCompletionEngine {
}
@Override
- public Object next() {
+ public String next() {
if (!fHasNext) {
throw new NoSuchElementException();
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
index 3b5f632d590..019841b7aea 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
@@ -48,7 +48,7 @@ public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistr
/** The last edit position */
private EditPosition fLastEditPosition;
/** The action which goes to the last edit position */
- private Set fLastEditPositionDependentActions;
+ private Set<IAction> fLastEditPositionDependentActions;
/**
* The quick diff extension registry.
@@ -112,9 +112,9 @@ public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistr
public void setLastEditPosition(EditPosition lastEditPosition) {
fLastEditPosition= lastEditPosition;
if (fLastEditPosition != null && fLastEditPositionDependentActions != null) {
- Iterator iter= fLastEditPositionDependentActions.iterator();
+ Iterator<IAction> iter= fLastEditPositionDependentActions.iterator();
while (iter.hasNext())
- ((IAction)iter.next()).setEnabled(true);
+ iter.next().setEnabled(true);
fLastEditPositionDependentActions= null;
}
}
@@ -128,7 +128,7 @@ public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistr
if (fLastEditPosition != null)
return;
if (fLastEditPositionDependentActions == null)
- fLastEditPositionDependentActions= new HashSet();
+ fLastEditPositionDependentActions= new HashSet<>();
fLastEditPositionDependentActions.add(action);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java
index 56b17981fff..cbf11320944 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.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
@@ -35,7 +35,7 @@ public final class DiffRegion extends Annotation implements ILineDiffInfo {
private final int fOffset;
- private final List fList;
+ private final List<QuickDiffRangeDifference> fList;
private final IDocument fDocument;
@@ -47,7 +47,7 @@ public final class DiffRegion extends Annotation implements ILineDiffInfo {
* @param differences the list of differences
* @param source the document
*/
- public DiffRegion(QuickDiffRangeDifference difference, int offset, List differences, IDocument source) {
+ public DiffRegion(QuickDiffRangeDifference difference, int offset, List<QuickDiffRangeDifference> differences, IDocument source) {
super("org.eclipse.ui.workbench.texteditor.quickdiffChange", false, null); //$NON-NLS-1$
fOffset= offset;
fDifference= difference;
@@ -85,10 +85,10 @@ public final class DiffRegion extends Annotation implements ILineDiffInfo {
return Math.max(fDifference.leftLength() - fDifference.rightLength(), 0);
synchronized (fList) {
- for (ListIterator it= fList.listIterator(); it.hasNext();) {
+ for (ListIterator<QuickDiffRangeDifference> it= fList.listIterator(); it.hasNext();) {
if (fDifference.equals(it.next())) {
if (it.hasNext()) {
- QuickDiffRangeDifference next= (QuickDiffRangeDifference) it.next();
+ QuickDiffRangeDifference next= it.next();
if (next.rightLength() == 0)
return Math.max(next.leftLength() - next.rightLength(), 0);
}
@@ -113,10 +113,10 @@ public final class DiffRegion extends Annotation implements ILineDiffInfo {
public int getRemovedLinesAbove() {
if (getChangeType() == UNCHANGED && fOffset == 0) {
synchronized (fList) {
- for (ListIterator it= fList.listIterator(fList.size()); it.hasPrevious();) {
+ for (ListIterator<QuickDiffRangeDifference> it= fList.listIterator(fList.size()); it.hasPrevious();) {
if (fDifference.equals(it.previous())) {
if (it.hasPrevious()) {
- QuickDiffRangeDifference previous= (QuickDiffRangeDifference) it.previous();
+ QuickDiffRangeDifference previous= it.previous();
return Math.max(previous.leftLength() - previous.rightLength(), 0);
}
break;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
index 0a60484b609..1f4b5aab26a 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 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
@@ -172,31 +172,31 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
*/
private boolean fUpdateNeeded;
/** The listeners on this annotation model. */
- private List fAnnotationModelListeners= new ArrayList();
+ private List<IAnnotationModelListener> fAnnotationModelListeners= new ArrayList<>();
/** The job currently initializing the differ, or <code>null</code> if there is none. */
private Job fInitializationJob;
/** Stores <code>DocumentEvents</code> while an initialization is going on. */
- private List fStoredEvents= new ArrayList();
+ private List<DocumentEvent> fStoredEvents= new ArrayList<>();
/**
* The differences between <code>fLeftDocument</code> and <code>fRightDocument</code>.
* This is the model we work on.
*/
- private List fDifferences= new ArrayList();
+ private List<QuickDiffRangeDifference> fDifferences= new ArrayList<>();
/**
* The differences removed in one iteration. Stored to be able to send out differentiated
* annotation events.
*/
- private List fRemoved= new ArrayList();
+ private List<QuickDiffRangeDifference> fRemoved= new ArrayList<>();
/**
* The differences added in one iteration. Stored to be able to send out differentiated
* annotation events.
*/
- private List fAdded= new ArrayList();
+ private List<QuickDiffRangeDifference> fAdded= new ArrayList<>();
/**
* The differences changed in one iteration. Stored to be able to send out differentiated
* annotation events.
*/
- private List fChanged= new ArrayList();
+ private List<QuickDiffRangeDifference> fChanged= new ArrayList<>();
/** The first line affected by a document event. */
private int fFirstLine;
/** The number of lines affected by a document event. */
@@ -330,13 +330,13 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
int rOffset= -1, rLength= -1, lOffset= -1, lLength= -1;
QuickDiffRangeDifference diff= null;
- final List differences= fDifferences;
+ final List<QuickDiffRangeDifference> differences= fDifferences;
synchronized (differences) {
- Iterator it= differences.iterator();
+ Iterator<QuickDiffRangeDifference> it= differences.iterator();
// get start
while (it.hasNext()) {
- diff= (QuickDiffRangeDifference) it.next();
+ diff= it.next();
if (line < diff.rightEnd()) {
rOffset= fRightDocument.getLineOffset(line);
int leftLine= Math.min(diff.leftStart() + line - diff.rightStart(), diff.leftEnd() - 1);
@@ -351,7 +351,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// get end / length
int to= line + nLines - 1;
while (it.hasNext()) {
- diff= (QuickDiffRangeDifference) it.next();
+ diff= it.next();
if (to < diff.rightEnd()) {
int rEndOffset= fRightDocument.getLineOffset(to) + fRightDocument.getLineLength(to);
rLength= rEndOffset - rOffset;
@@ -382,13 +382,13 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
return 0;
QuickDiffRangeDifference diff= null;
- final List differences= fDifferences;
+ final List<QuickDiffRangeDifference> differences= fDifferences;
synchronized (differences) {
- for (Iterator it= differences.iterator(); it.hasNext();) {
- diff= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= differences.iterator(); it.hasNext();) {
+ diff= it.next();
if (line >= diff.rightStart() && line < diff.rightEnd()) {
if (diff.kind() == RangeDifference.NOCHANGE && it.hasNext())
- diff= (QuickDiffRangeDifference) it.next();
+ diff= it.next();
break;
}
}
@@ -626,7 +626,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
DocumentEquivalenceClass rightEquivalent= new DocumentEquivalenceClass(actual, hash);
fRightEquivalent= rightEquivalent;
IRangeComparator act= new DocEquivalenceComparator(rightEquivalent, null);
- List diffs= new ArrayList(Arrays.asList(RangeDifferencer.findRanges(fRangeDiffFactory, monitor, ref, act)));
+ ArrayList<QuickDiffRangeDifference> diffs= asQuickDiffRangeDifference(RangeDifferencer.findRanges(fRangeDiffFactory, monitor, ref, act));
// 7: Reset the model to the just gotten differences
// re-inject stored events to get up to date.
synchronized (DocumentLineDiffer.this) {
@@ -658,7 +658,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
break;
}
- event= (DocumentEvent) fStoredEvents.remove(0);
+ event= fStoredEvents.remove(0);
}
// access documents non synchronized:
@@ -861,16 +861,16 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// inform listeners about change
if (fUpdateNeeded) {
AnnotationModelEvent ame= new AnnotationModelEvent(this, false);
- for (Iterator it= fAdded.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= fAdded.iterator(); it.hasNext(); ) {
+ QuickDiffRangeDifference rd= it.next();
ame.annotationAdded(rd.getDiffRegion(fDifferences, fLeftDocument));
}
- for (Iterator it= fRemoved.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= fRemoved.iterator(); it.hasNext(); ) {
+ QuickDiffRangeDifference rd= it.next();
ame.annotationRemoved(rd.getDiffRegion(fDifferences, fLeftDocument));
}
- for (Iterator it= fChanged.iterator(); it.hasNext(); ) {
- QuickDiffRangeDifference rd= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= fChanged.iterator(); it.hasNext(); ) {
+ QuickDiffRangeDifference rd= it.next();
ame.annotationChanged(rd.getDiffRegion(fDifferences, fLeftDocument));
}
fireModelChanged(ame);
@@ -1006,29 +1006,29 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// ">\n\n<" + right.get(rightRegion.getOffset(), rightRegion.getLength()) + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$
// compare
- List diffs= new ArrayList(Arrays.asList(RangeDifferencer.findRanges(fRangeDiffFactory, null, reference, change)));
+ List<QuickDiffRangeDifference> diffs= asQuickDiffRangeDifference(RangeDifferencer.findRanges(fRangeDiffFactory, null, reference, change));
if (diffs.size() == 0) {
diffs.add(new QuickDiffRangeDifference(RangeDifference.CHANGE, 0, 0, 0, 0));
}
// shift the partial diffs to the absolute document positions
- for (Iterator it= diffs.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= diffs.iterator(); it.hasNext();) {
+ QuickDiffRangeDifference d= it.next();
d.shiftLeft(leftStartLine);
d.shiftRight(rightStartLine);
}
// undo optimization shifting
if (shiftBefore > 0) {
- QuickDiffRangeDifference first= (QuickDiffRangeDifference) diffs.get(0);
+ QuickDiffRangeDifference first= diffs.get(0);
if (first.kind() == RangeDifference.NOCHANGE)
first.extendStart(-shiftBefore);
else
diffs.add(0, new QuickDiffRangeDifference(RangeDifference.NOCHANGE, first.rightStart() - shiftBefore, shiftBefore, first.leftStart() - shiftBefore, shiftBefore));
}
- QuickDiffRangeDifference last= (QuickDiffRangeDifference) diffs.get(diffs.size() - 1);
+ QuickDiffRangeDifference last= diffs.get(diffs.size() - 1);
if (shiftAfter > 0) {
if (last.kind() == RangeDifference.NOCHANGE)
last.extendEnd(shiftAfter);
@@ -1038,8 +1038,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// replace changed diff range
synchronized (fDifferences) {
- final ListIterator it= fDifferences.listIterator();
- Iterator newIt= diffs.iterator();
+ final ListIterator<QuickDiffRangeDifference> it= fDifferences.listIterator();
+ Iterator<QuickDiffRangeDifference> newIt= diffs.iterator();
QuickDiffRangeDifference current;
boolean changed= false;
@@ -1048,7 +1048,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// search for consistentBefore
do {
Assert.isTrue(it.hasNext());
- current= (QuickDiffRangeDifference) it.next();
+ current= it.next();
} while (current != consistentBefore);
Assert.isTrue(current == consistentBefore);
@@ -1059,7 +1059,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// replace until consistentAfter
while (current != consistentAfter) {
if (newIt.hasNext()) {
- Object o= newIt.next();
+ QuickDiffRangeDifference o= newIt.next();
if (!current.equals(o)) {
fRemoved.add(current);
fAdded.add(o);
@@ -1072,13 +1072,13 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
changed= true;
}
Assert.isTrue(it.hasNext());
- current= (QuickDiffRangeDifference) it.next();
+ current= it.next();
}
// replace consistentAfter
Assert.isTrue(current == consistentAfter);
if (newIt.hasNext()) {
- Object o= newIt.next();
+ QuickDiffRangeDifference o= newIt.next();
if (!current.equals(o)) {
fRemoved.add(current);
fAdded.add(o);
@@ -1093,7 +1093,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
// add remaining new diffs
while (newIt.hasNext()) {
- Object next= newIt.next();
+ QuickDiffRangeDifference next= newIt.next();
fAdded.add(next);
it.add(next);
changed= true;
@@ -1104,7 +1104,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
int leftShift= 0;
int rightShift= 0;
while (it.hasNext()) {
- current= (QuickDiffRangeDifference) it.next();
+ current= it.next();
if (init) {
init= false;
leftShift= last.leftEnd() - current.leftStart();
@@ -1126,6 +1126,19 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
}
/**
+ * Converts a {@code RangeDifference[]} into an {@code ArrayList<QuickDiffRangeDifference>}.
+ * This is unsafe in general, but OK if used carefully.
+ * Workaround for <a href="https://bugs.eclipse.org/483319">bug 483319</a>.
+ *
+ * @param ranges the ranges, <em>must</em> be of type {@link QuickDiffRangeDifference}
+ * @return the ranges as a modifiable list
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ private static ArrayList<QuickDiffRangeDifference> asQuickDiffRangeDifference(RangeDifference[] ranges) {
+ return new ArrayList(Arrays.asList(ranges));
+ }
+
+ /**
* Finds a consistent range of at least size before <code>line</code> in the left document.
*
* @param line the line before which the range has to occur
@@ -1135,8 +1148,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
private QuickDiffRangeDifference findConsistentRangeBeforeLeft(int line, int size) {
QuickDiffRangeDifference found= null;
- for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
- QuickDiffRangeDifference difference= (QuickDiffRangeDifference) it.next();
+ for (ListIterator<QuickDiffRangeDifference> it= fDifferences.listIterator(); it.hasNext();) {
+ QuickDiffRangeDifference difference= it.next();
if (found == null || difference.kind() == RangeDifference.NOCHANGE
&& (difference.leftEnd() < line && difference.leftLength() >= size
|| difference.leftEnd() >= line && line - difference.leftStart() >= size))
@@ -1159,8 +1172,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
private QuickDiffRangeDifference findConsistentRangeAfterLeft(int line, int size) {
QuickDiffRangeDifference found= null;
- for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
- QuickDiffRangeDifference difference= (QuickDiffRangeDifference) it.previous();
+ for (ListIterator<QuickDiffRangeDifference> it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
+ QuickDiffRangeDifference difference= it.previous();
if (found == null || difference.kind() == RangeDifference.NOCHANGE
&& (difference.leftStart() > line && difference.leftLength() >= size
|| difference.leftStart() <= line && difference.leftEnd() - line >= size))
@@ -1185,8 +1198,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
QuickDiffRangeDifference found= null;
int unchanged= -1; // the number of unchanged lines before line
- for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
- QuickDiffRangeDifference difference= (QuickDiffRangeDifference) it.next();
+ for (ListIterator<QuickDiffRangeDifference> it= fDifferences.listIterator(); it.hasNext();) {
+ QuickDiffRangeDifference difference= it.next();
if (found == null)
found= difference;
else if (difference.kind() == RangeDifference.NOCHANGE) {
@@ -1213,8 +1226,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
QuickDiffRangeDifference found= null;
int unchanged= -1; // the number of unchanged lines after line
- for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
- QuickDiffRangeDifference difference= (QuickDiffRangeDifference) it.previous();
+ for (ListIterator<QuickDiffRangeDifference> it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
+ QuickDiffRangeDifference difference= it.previous();
if (found == null)
found= difference;
else if (difference.kind() == RangeDifference.NOCHANGE) {
@@ -1273,7 +1286,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
*
* Q: what if we have a prefix to a repetition field? Probably does not matter.
*/
- LinkedList window= new LinkedList();
+ LinkedList<String> window= new LinkedList<>();
int nLines= doc.getNumberOfLines();
int repetition= line - 1;
int l= line;
@@ -1337,8 +1350,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @return the corresponding RangeDifference, or <code>null</code>
*/
private QuickDiffRangeDifference getRangeDifferenceForLeftLine(int leftLine) {
- for (Iterator it= fDifferences.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= fDifferences.iterator(); it.hasNext();) {
+ QuickDiffRangeDifference d= it.next();
if (leftLine >= d.leftStart() && leftLine < d.leftEnd()) {
return d;
}
@@ -1353,10 +1366,10 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @return the corresponding RangeDifference, or <code>null</code>
*/
private QuickDiffRangeDifference getRangeDifferenceForRightLine(int rightLine) {
- final List differences= fDifferences;
+ final List<QuickDiffRangeDifference> differences= fDifferences;
synchronized (differences) {
- for (Iterator it= differences.iterator(); it.hasNext();) {
- QuickDiffRangeDifference d= (QuickDiffRangeDifference) it.next();
+ for (Iterator<QuickDiffRangeDifference> it= differences.iterator(); it.hasNext();) {
+ QuickDiffRangeDifference d= it.next();
if (rightLine >= d.rightStart() && rightLine < d.rightEnd()) {
return d;
}
@@ -1449,14 +1462,14 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
}
@Override
- public Iterator getAnnotationIterator() {
- final List copy;
- List differences= fDifferences; // atomic
+ public Iterator<Annotation> getAnnotationIterator() {
+ final List<QuickDiffRangeDifference> copy;
+ List<QuickDiffRangeDifference> differences= fDifferences; // atomic
synchronized (differences) {
- copy= new ArrayList(differences);
+ copy= new ArrayList<>(differences);
}
- final Iterator iter= copy.iterator();
- return new Iterator() {
+ final Iterator<QuickDiffRangeDifference> iter= copy.iterator();
+ return new Iterator<Annotation>() {
@Override
public void remove() {
@@ -1469,8 +1482,8 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
}
@Override
- public Object next() {
- QuickDiffRangeDifference diff= (QuickDiffRangeDifference) iter.next();
+ public Annotation next() {
+ QuickDiffRangeDifference diff= iter.next();
return diff.getDiffRegion(copy, fLeftDocument);
}
@@ -1507,10 +1520,10 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @param event the event to be sent out to the listeners
*/
protected void fireModelChanged(AnnotationModelEvent event) {
- ArrayList v= new ArrayList(fAnnotationModelListeners);
- Iterator e= v.iterator();
+ ArrayList<IAnnotationModelListener> v= new ArrayList<>(fAnnotationModelListeners);
+ Iterator<IAnnotationModelListener> e= v.iterator();
while (e.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener)e.next();
+ IAnnotationModelListener l= e.next();
if (l instanceof IAnnotationModelListenerExtension)
((IAnnotationModelListenerExtension)l).modelChanged(event);
else
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
index 5598cf7894f..a7f3c96b561 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
@@ -32,7 +32,7 @@ public class QuickDiffExtensionsRegistry {
/** The default reference provider's descriptor. */
private ReferenceProviderDescriptor fDefaultDescriptor;
/** The list returned to callers of <code>getExtensions</code>. */
- private List fDescriptors;
+ private List<ReferenceProviderDescriptor> fDescriptors;
/**
* Creates a new instance.
@@ -56,7 +56,7 @@ public class QuickDiffExtensionsRegistry {
*
* @return the list of extensions to the <code>quickDiffReferenceProvider</code> extension point.
*/
- public synchronized List getReferenceProviderDescriptors() {
+ public synchronized List<ReferenceProviderDescriptor> getReferenceProviderDescriptors() {
ensureRegistered();
return fDescriptors;
}
@@ -79,7 +79,7 @@ public class QuickDiffExtensionsRegistry {
public synchronized void reloadExtensions() {
fDefaultDescriptor= null;
IExtensionRegistry registry= Platform.getExtensionRegistry();
- List list= new ArrayList();
+ List<ReferenceProviderDescriptor> list= new ArrayList<>();
IConfigurationElement[] elements= registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.java
index fd1bb329944..76d2d5d9009 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRangeDifference.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
@@ -117,7 +117,7 @@ public class QuickDiffRangeDifference extends org.eclipse.compare.rangedifferenc
* @param source the original document (left document) that this difference refers to
* @return a <code>DiffRegion</code> corresponding to this difference
*/
- public DiffRegion getDiffRegion(List differences, IDocument source) {
+ public DiffRegion getDiffRegion(List<QuickDiffRangeDifference> differences, IDocument source) {
if (fRegion == null)
fRegion= new DiffRegion(this, 0, differences, source);
return fRegion;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java
index 440cb70f6ac..29fa1f82a84 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/equivalence/DocumentEquivalenceClass.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -29,7 +29,7 @@ public final class DocumentEquivalenceClass {
private static final boolean DEBUG= false;
- private final ArrayList fHashes;
+ private final ArrayList<Hash> fHashes;
private IDocument fDocument;
private final IHashFunction fHashFunction;
@@ -39,8 +39,8 @@ public final class DocumentEquivalenceClass {
public DocumentEquivalenceClass(IDocument document, IHashFunction hashFunction) {
fDocument= document;
- Object[] nulls= new Object[fDocument.getNumberOfLines()];
- fHashes= new ArrayList(Arrays.asList(nulls));
+ Hash[] nulls= new Hash[fDocument.getNumberOfLines()];
+ fHashes= new ArrayList<>(Arrays.asList(nulls));
if (hashFunction == null)
throw new NullPointerException("hashFunction"); //$NON-NLS-1$
@@ -67,7 +67,7 @@ public final class DocumentEquivalenceClass {
}
private Hash internalGetHash(int line) throws BadLocationException {
- Hash hash= (Hash) fHashes.get(line);
+ Hash hash= fHashes.get(line);
if (hash == null) {
if (fDocument == null)
throw new AssertionError("hash cannot be null after loadAndForget"); //$NON-NLS-1$
@@ -108,7 +108,7 @@ public final class DocumentEquivalenceClass {
int changed= Math.min(linesAfter, linesBefore);
if (delta > 0) {
- Object[] nulls= new Object[delta];
+ Hash[] nulls= new Hash[delta];
fHashes.addAll(firstLine + changed, Arrays.asList(nulls));
} else if (delta < 0) {
fHashes.subList(firstLine, firstLine - delta).clear();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
index 144db9644d2..aa5024239dd 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/DAG.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -21,15 +21,18 @@ import org.eclipse.core.runtime.Assert;
/**
* A directed acyclic graph. See http://en.wikipedia.org/wiki/Directed_acyclic_graph
+ * @param <E> type of the vertices
*
* @since 3.3
*/
-public final class DAG {
+public final class DAG<E> {
/**
* Multimap, supports <code>null</code> key, but not <code>null</code> values.
+ * @param <K> key type
+ * @param <V> values type
*/
- private static final class MultiMap {
- private final Map fMap= new LinkedHashMap();
+ private static final class MultiMap<K, V> {
+ private final Map<K, Set<V>> fMap= new LinkedHashMap<>();
/**
* Adds <code>val</code> to the values mapped to by <code>key</code>. If
@@ -39,10 +42,10 @@ public final class DAG {
* @param key the key
* @param val the value
*/
- public void put(Object key, Object val) {
- Set values= (Set) fMap.get(key);
+ public void put(K key, V val) {
+ Set<V> values= fMap.get(key);
if (values == null) {
- values= new LinkedHashSet();
+ values= new LinkedHashSet<>();
fMap.put(key, values);
}
if (val != null)
@@ -55,12 +58,12 @@ public final class DAG {
* @param key the key
* @return the mappings for <code>key</code>
*/
- public Set get(Object key) {
- Set values= (Set) fMap.get(key);
- return values == null ? Collections.EMPTY_SET : values;
+ public Set<V> get(K key) {
+ Set<V> values= fMap.get(key);
+ return values == null ? Collections.emptySet() : values;
}
- public Set keySet() {
+ public Set<K> keySet() {
return fMap.keySet();
}
@@ -71,9 +74,9 @@ public final class DAG {
* @param key the key to remove
* @return the removed mappings
*/
- public Set removeAll(Object key) {
- Set values= (Set) fMap.remove(key);
- return values == null ? Collections.EMPTY_SET : values;
+ public Set<V> removeAll(K key) {
+ Set<V> values= fMap.remove(key);
+ return values == null ? Collections.emptySet() : values;
}
/**
@@ -83,8 +86,8 @@ public final class DAG {
* @param key the key
* @param val the value
*/
- public void remove(Object key, Object val) {
- Set values= (Set) fMap.get(key);
+ public void remove(K key, V val) {
+ Set<V> values= fMap.get(key);
if (values != null)
values.remove(val);
}
@@ -95,8 +98,8 @@ public final class DAG {
}
}
- private final MultiMap fOut= new MultiMap();
- private final MultiMap fIn= new MultiMap();
+ private final MultiMap<E, E> fOut= new MultiMap<>();
+ private final MultiMap<E, E> fIn= new MultiMap<>();
/**
* Adds a directed edge from <code>origin</code> to <code>target</code>. The vertices are not
@@ -109,7 +112,7 @@ public final class DAG {
* edge was not added because it would have violated the acyclic nature of the
* receiver.
*/
- public boolean addEdge(Object origin, Object target) {
+ public boolean addEdge(E origin, E target) {
Assert.isLegal(origin != null);
Assert.isLegal(target != null);
@@ -129,7 +132,7 @@ public final class DAG {
*
* @param vertex the new vertex
*/
- public void addVertex(Object vertex) {
+ public void addVertex(E vertex) {
Assert.isLegal(vertex != null);
fOut.put(vertex, null);
fIn.put(vertex, null);
@@ -140,12 +143,12 @@ public final class DAG {
*
* @param vertex the vertex to remove
*/
- public void removeVertex(Object vertex) {
- Set targets= fOut.removeAll(vertex);
- for (Iterator it= targets.iterator(); it.hasNext();)
+ public void removeVertex(E vertex) {
+ Set<E> targets= fOut.removeAll(vertex);
+ for (Iterator<E> it= targets.iterator(); it.hasNext();)
fIn.remove(it.next(), vertex);
- Set origins= fIn.removeAll(vertex);
- for (Iterator it= origins.iterator(); it.hasNext();)
+ Set<E> origins= fIn.removeAll(vertex);
+ for (Iterator<E> it= origins.iterator(); it.hasNext();)
fOut.remove(it.next(), vertex);
}
@@ -155,7 +158,7 @@ public final class DAG {
*
* @return the sources of the receiver
*/
- public Set getSources() {
+ public Set<E> getSources() {
return computeZeroEdgeVertices(fIn);
}
@@ -165,15 +168,15 @@ public final class DAG {
*
* @return the sinks of the receiver
*/
- public Set getSinks() {
+ public Set<E> getSinks() {
return computeZeroEdgeVertices(fOut);
}
- private Set computeZeroEdgeVertices(MultiMap map) {
- Set candidates= map.keySet();
- Set roots= new LinkedHashSet(candidates.size());
- for (Iterator it= candidates.iterator(); it.hasNext();) {
- Object candidate= it.next();
+ private static <T> Set<T> computeZeroEdgeVertices(MultiMap<T, T> map) {
+ Set<T> candidates= map.keySet();
+ Set<T> roots= new LinkedHashSet<>(candidates.size());
+ for (Iterator<T> it= candidates.iterator(); it.hasNext();) {
+ T candidate= it.next();
if (map.get(candidate).isEmpty())
roots.add(candidate);
}
@@ -186,17 +189,17 @@ public final class DAG {
* @param vertex the parent vertex
* @return the direct children of <code>vertex</code>
*/
- public Set getChildren(Object vertex) {
+ public Set<E> getChildren(E vertex) {
return Collections.unmodifiableSet(fOut.get(vertex));
}
- private boolean hasPath(Object start, Object end) {
+ private boolean hasPath(E start, E end) {
// break condition
if (start == end)
return true;
- Set children= fOut.get(start);
- for (Iterator it= children.iterator(); it.hasNext();)
+ Set<E> children= fOut.get(start);
+ for (Iterator<E> it= children.iterator(); it.hasNext();)
// recursion
if (hasPath(it.next(), end))
return true;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
index feed84be7f2..29a810b0344 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnPlacement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -37,12 +37,12 @@ public final class RulerColumnPlacement {
/** The placement gravity. */
private final float fGravity;
- /** The placement constraints (element type: {@link RulerColumnPlacementConstraint}). */
- private final Set fConstraints;
+ /** The placement constraints. */
+ private final Set<RulerColumnPlacementConstraint> fConstraints;
public RulerColumnPlacement() {
fGravity= 1f;
- fConstraints= Collections.EMPTY_SET;
+ fConstraints= Collections.emptySet();
}
public RulerColumnPlacement(IConfigurationElement element) throws InvalidRegistryObjectException, CoreException {
@@ -55,8 +55,8 @@ public final class RulerColumnPlacement {
fConstraints= readIds(element.getChildren());
}
- private Set readIds(IConfigurationElement[] children) throws CoreException {
- Set constraints= new LinkedHashSet((int) (children.length / 0.75) + 1, 0.75f);
+ private Set<RulerColumnPlacementConstraint> readIds(IConfigurationElement[] children) throws CoreException {
+ Set<RulerColumnPlacementConstraint> constraints= new LinkedHashSet<>((int) (children.length / 0.75) + 1, 0.75f);
for (int i= 0; i < children.length; i++) {
IConfigurationElement child= children[i];
String name= child.getName();
@@ -90,7 +90,7 @@ public final class RulerColumnPlacement {
* @return the unmodifiable set of placement constraints in the order that they appear in the
* extension declaration
*/
- public Set getConstraints() {
+ public Set<RulerColumnPlacementConstraint> getConstraints() {
return fConstraints;
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java
index 82022b3266e..a33af906d00 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/RulerColumnTarget.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -23,7 +23,7 @@ import org.eclipse.core.runtime.content.IContentType;
public abstract class RulerColumnTarget {
public abstract boolean matchesEditorId(String editorId);
public abstract boolean matchesContentType(IContentType contentType);
- public abstract boolean matchesClass(Class clazz);
+ public abstract boolean matchesClass(Class<?> clazz);
/* package visible */
RulerColumnTarget() {
@@ -70,7 +70,7 @@ final class AllTarget extends RulerColumnTarget {
}
@Override
- public boolean matchesClass(Class clazz) {
+ public boolean matchesClass(Class<?> clazz) {
return true;
}
@@ -102,7 +102,7 @@ final class OrTarget extends RulerColumnTarget {
}
@Override
- public boolean matchesClass(Class clazz) {
+ public boolean matchesClass(Class<?> clazz) {
return fEither.matchesClass(clazz) || fOr.matchesClass(clazz);
}
@@ -131,7 +131,7 @@ final class EditorIdTarget extends RulerColumnTarget {
}
@Override
- public boolean matchesClass(Class clazz) {
+ public boolean matchesClass(Class<?> clazz) {
return false;
}
@@ -160,7 +160,7 @@ final class ClassTarget extends RulerColumnTarget {
}
@Override
- public boolean matchesClass(Class clazz) {
+ public boolean matchesClass(Class<?> clazz) {
Assert.isLegal(clazz != null);
do {
@@ -197,7 +197,7 @@ final class ContentTypeTarget extends RulerColumnTarget {
}
@Override
- public boolean matchesClass(Class clazz) {
+ public boolean matchesClass(Class<?> clazz) {
return false;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java
index 7da15e2310d..628469844d5 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/rulers/StringSetSerializer.java
@@ -22,20 +22,20 @@ public final class StringSetSerializer {
private StringSetSerializer() {
}
- public static String serialize(Set strings) {
+ public static String serialize(Set<String> strings) {
Assert.isLegal(strings != null);
StringBuffer buf= new StringBuffer(strings.size() * 20);
- for (Iterator it= strings.iterator(); it.hasNext();) {
- buf.append((String) it.next());
+ for (Iterator<String> it= strings.iterator(); it.hasNext();) {
+ buf.append(it.next());
if (it.hasNext())
buf.append(DELIM);
}
return buf.toString();
}
- public static Set deserialize(String serialized) {
+ public static Set<String> deserialize(String serialized) {
Assert.isLegal(serialized != null);
- Set marked= new HashSet();
+ Set<String> marked= new HashSet<>();
StringTokenizer tok= new StringTokenizer(serialized, DELIM);
while (tok.hasMoreTokens())
marked.add(tok.nextToken());
@@ -43,13 +43,13 @@ public final class StringSetSerializer {
}
public static String[] getDifference(String oldValue, String newValue) {
- Set oldSet= deserialize(oldValue);
- Set newSet= deserialize(newValue);
- Set intersection= new HashSet(oldSet);
+ Set<String> oldSet= deserialize(oldValue);
+ Set<String> newSet= deserialize(newValue);
+ Set<String> intersection= new HashSet<>(oldSet);
intersection.retainAll(newSet);
oldSet.removeAll(intersection);
newSet.removeAll(intersection);
oldSet.addAll(newSet);
- return (String[]) oldSet.toArray(new String[oldSet.size()]);
+ return oldSet.toArray(new String[oldSet.size()]);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
index 7ef9e660e61..ce33b3beaf0 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/spelling/SpellingEngineRegistry.java
@@ -40,7 +40,7 @@ public class SpellingEngineRegistry {
public static final String SPELLING_ENGINE_EXTENSION_POINT= "spellingEngine"; //$NON-NLS-1$
/** Ids mapped to descriptors */
- private Map fDescriptorsMap;
+ private Map<String, SpellingEngineDescriptor> fDescriptorsMap;
/** Default descriptor or <code>null</code> */
private SpellingEngineDescriptor fDefaultDescriptor;
@@ -60,7 +60,7 @@ public class SpellingEngineRegistry {
*/
public SpellingEngineDescriptor getDescriptor(String id) {
ensureExtensionsLoaded();
- return (SpellingEngineDescriptor) fDescriptorsMap.get(id);
+ return fDescriptorsMap.get(id);
}
/**
@@ -91,8 +91,8 @@ public class SpellingEngineRegistry {
* </p>
*/
public synchronized void reloadExtensions() {
- List descriptors= new ArrayList();
- fDescriptorsMap= new HashMap();
+ List<SpellingEngineDescriptor> descriptors= new ArrayList<>();
+ fDescriptorsMap= new HashMap<>();
fDefaultDescriptor= null;
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, SPELLING_ENGINE_EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
@@ -102,7 +102,7 @@ public class SpellingEngineRegistry {
if (fDefaultDescriptor == null && descriptor.isDefault())
fDefaultDescriptor= descriptor;
}
- fDescriptors= (SpellingEngineDescriptor[]) descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]);
+ fDescriptors= descriptors.toArray(new SpellingEngineDescriptor[descriptors.size()]);
fLoaded= true;
if (fDefaultDescriptor == null && fDescriptors.length > 0)
fDefaultDescriptor= fDescriptors[0];
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java
index 67817ccf1fa..3b54aa99d8e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.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
@@ -186,9 +186,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
/** Element information of all connected elements */
- private Map fElementInfoMap= new HashMap();
+ private Map<Object, ElementInfo> fElementInfoMap= new HashMap<>();
/** The element state listeners */
- private List fElementStateListeners= new ArrayList();
+ private List<IElementStateListener> fElementStateListeners= new ArrayList<>();
/**
* The current progress monitor
* @since 2.1
@@ -306,7 +306,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @return the element info object, or <code>null</code> if none
*/
protected ElementInfo getElementInfo(Object element) {
- return (ElementInfo) fElementInfoMap.get(element);
+ return fElementInfoMap.get(element);
}
/**
@@ -374,11 +374,11 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
/**
* Enumerates the elements connected via this document provider.
*
- * @return the list of elements (element type: <code>Object</code>)
+ * @return the list of elements
*/
- protected Iterator getConnectedElements() {
- Set s= new HashSet();
- Set keys= fElementInfoMap.keySet();
+ protected Iterator<Object> getConnectedElements() {
+ Set<Object> s= new HashSet<>();
+ Set<Object> keys= fElementInfoMap.keySet();
if (keys != null)
s.addAll(keys);
return s.iterator();
@@ -386,7 +386,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
public final void connect(Object element) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info == null) {
info= createElementInfo(element);
@@ -418,7 +418,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
*/
@Override
public final void disconnect(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info == null)
return;
@@ -451,7 +451,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
if (element == null)
return null;
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
return (info != null ? info.fDocument : null);
}
@@ -461,7 +461,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
if (element == null)
return false;
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
return (info != null ? info.fCount == 1 && info.fCanBeSaved : false);
}
@@ -471,7 +471,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
if (element == null)
return null;
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
return (info != null ? info.fModel : null);
}
@@ -481,7 +481,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
if (element == null)
return false;
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
return (info != null ? info.fCanBeSaved : false);
}
@@ -494,7 +494,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @since 3.0
*/
protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null) {
IDocument original= null;
@@ -581,7 +581,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
protected void execute(IProgressMonitor pm) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null) {
if (info.fDocument != document) {
Status status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, EditorMessages.AbstractDocumentProvider_error_save_inuse, null);
@@ -655,9 +655,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @see IElementStateListener#elementDirtyStateChanged(Object, boolean)
*/
protected void fireElementDirtyStateChanged(Object element, boolean isDirty) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
+ IElementStateListener l= e.next();
l.elementDirtyStateChanged(element, isDirty);
}
}
@@ -670,9 +670,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @see IElementStateListener#elementContentAboutToBeReplaced(Object)
*/
protected void fireElementContentAboutToBeReplaced(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
+ IElementStateListener l= e.next();
l.elementContentAboutToBeReplaced(element);
}
}
@@ -685,9 +685,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @see IElementStateListener#elementContentReplaced(Object)
*/
protected void fireElementContentReplaced(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
+ IElementStateListener l= e.next();
l.elementContentReplaced(element);
}
}
@@ -700,9 +700,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @see IElementStateListener#elementDeleted(Object)
*/
protected void fireElementDeleted(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
+ IElementStateListener l= e.next();
l.elementDeleted(element);
}
}
@@ -715,9 +715,9 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @see IElementStateListener#elementMoved(Object, Object)
*/
protected void fireElementMoved(Object originalElement, Object movedElement) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
+ IElementStateListener l= e.next();
l.elementMoved(originalElement, movedElement);
}
}
@@ -757,7 +757,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
*/
@Override
public boolean isStateValidated(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null)
return info.fIsStateValidated;
return false;
@@ -784,7 +784,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
protected void execute(IProgressMonitor monitor) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info == null)
return;
@@ -834,7 +834,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
public final void updateStateCache(Object element) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null) {
boolean wasReadOnly= isReadOnly(element);
doUpdateStateCache(element);
@@ -848,7 +848,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
public void setCanSaveDocument(Object element) {
if (element != null) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null) {
info.fCanBeSaved= true;
removeUnchangedElementListeners(element, info);
@@ -867,7 +867,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @since 2.0
*/
protected void fireElementStateValidationChanged(Object element, boolean isStateValidated) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
@@ -886,7 +886,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @since 2.0
*/
protected void fireElementStateChanging(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
@@ -905,7 +905,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
* @since 2.0
*/
protected void fireElementStateChangeFailed(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
+ Iterator<IElementStateListener> e= new ArrayList<>(fElementStateListeners).iterator();
while (e.hasNext()) {
Object o= e.next();
if (o instanceof IElementStateListenerExtension) {
@@ -917,7 +917,7 @@ public abstract class AbstractDocumentProvider implements IDocumentProvider, IDo
@Override
public IStatus getStatus(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
+ ElementInfo info= fElementInfoMap.get(element);
if (info != null) {
if (info.fStatus != null)
return info.fStatus;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
index e629458d009..0ad6d352156 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
@@ -324,7 +324,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
private static final int SINGLE_CARET_WIDTH= 1;
/**
- * The symbolic name of the block seletion mode font.
+ * The symbolic name of the block selection mode font.
*
* @since 3.5
*/
@@ -752,7 +752,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
ActionActivationCode code= null;
int size= fActivationCodes.size();
for (int i= 0; i < size; i++) {
- code= (ActionActivationCode) fActivationCodes.get(i);
+ code= fActivationCodes.get(i);
if (code.matches(event)) {
IAction action= getAction(code.fActionId);
if (action != null) {
@@ -1581,7 +1581,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
protected static class ColumnSupport implements IColumnSupport {
private final AbstractTextEditor fEditor;
private final RulerColumnRegistry fRegistry;
- private final List fColumns;
+ private final List<IContributedRulerColumn> fColumns;
/**
* Creates a new column support for the given editor. Only the editor itself should normally
@@ -1595,7 +1595,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
Assert.isLegal(registry != null);
fEditor= editor;
fRegistry= registry;
- fColumns= new ArrayList();
+ fColumns= new ArrayList<>();
}
@Override
@@ -1671,8 +1671,8 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @return the matching column or <code>null</code>
*/
private IContributedRulerColumn getVisibleColumn(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
- for (Iterator it= ruler.getDecoratorIterator(); it.hasNext();) {
- IVerticalRulerColumn column= (IVerticalRulerColumn)it.next();
+ for (Iterator<IVerticalRulerColumn> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= it.next();
if (column instanceof IContributedRulerColumn) {
IContributedRulerColumn rulerColumn= (IContributedRulerColumn)column;
RulerColumnDescriptor rcd= rulerColumn.getDescriptor();
@@ -1692,10 +1692,10 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) {
int index= 0;
- List all= fRegistry.getColumnDescriptors();
+ List<RulerColumnDescriptor> all= fRegistry.getColumnDescriptors();
int newPos= all.indexOf(descriptor);
- for (Iterator it= ruler.getDecoratorIterator(); it.hasNext();) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) it.next();
+ for (Iterator<IVerticalRulerColumn> it= ruler.getDecoratorIterator(); it.hasNext();) {
+ IVerticalRulerColumn column= it.next();
if (column instanceof IContributedRulerColumn) {
RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor();
if (rcd != null && all.indexOf(rcd) > newPos)
@@ -1746,8 +1746,8 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
@Override
public void dispose() {
- for (Iterator iter= new ArrayList(fColumns).iterator(); iter.hasNext();)
- removeColumn(getRuler(), (IContributedRulerColumn)iter.next());
+ for (Iterator<IContributedRulerColumn> iter= new ArrayList<>(fColumns).iterator(); iter.hasNext();)
+ removeColumn(getRuler(), iter.next());
fColumns.clear();
}
}
@@ -2402,23 +2402,23 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
/** The editor's presentation mode. */
private boolean fShowHighlightRangeOnly;
/** The actions registered with the editor. */
- private Map fActions= new HashMap(10);
+ private Map<String, IAction> fActions= new HashMap<>(10);
/** The actions marked as selection dependent. */
- private List fSelectionActions= new ArrayList(5);
+ private List<String> fSelectionActions= new ArrayList<>(5);
/** The actions marked as content dependent. */
- private List fContentActions= new ArrayList(5);
+ private List<String> fContentActions= new ArrayList<>(5);
/**
* The actions marked as property dependent.
* @since 2.0
*/
- private List fPropertyActions= new ArrayList(5);
+ private List<String> fPropertyActions= new ArrayList<>(5);
/**
* The actions marked as state dependent.
* @since 2.0
*/
- private List fStateActions= new ArrayList(5);
+ private List<String> fStateActions= new ArrayList<>(5);
/** The editor's action activation codes. */
- private List fActivationCodes= new ArrayList(2);
+ private List<ActionActivationCode> fActivationCodes= new ArrayList<>(2);
/** The verify key listener for activation code triggering. */
private ActivationCodeTrigger fActivationCodeTrigger= new ActivationCodeTrigger();
/** Context menu listener. */
@@ -2464,7 +2464,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* The map of the editor's status fields.
* @since 2.0
*/
- private Map fStatusFields;
+ private Map<String, IStatusField> fStatusFields;
/**
* The editor's cursor listener.
* @since 2.0
@@ -2509,7 +2509,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* Ruler context menu listeners.
* @since 2.0
*/
- private List fRulerContextMenuListeners= new ArrayList();
+ private List<IMenuListener> fRulerContextMenuListeners= new ArrayList<>();
/**
* Indicates whether sanity checking in enabled.
* @since 2.0
@@ -2549,7 +2549,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* The sequence of legal editor insert modes.
* @since 3.0
*/
- private List fLegalInsertModes= null;
+ private List<InsertMode> fLegalInsertModes= null;
/**
* The non-default caret.
* @since 3.0
@@ -3217,7 +3217,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 3.3
*/
protected void updateContributedRulerColumns(CompositeRuler ruler) {
- IColumnSupport support= (IColumnSupport)getAdapter(IColumnSupport.class);
+ IColumnSupport support= getAdapter(IColumnSupport.class);
if (support == null)
return;
@@ -3226,9 +3226,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS);
RulerColumnRegistry registry= RulerColumnRegistry.getDefault();
- List descriptors= registry.getColumnDescriptors();
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- final RulerColumnDescriptor descriptor= (RulerColumnDescriptor) it.next();
+ List<RulerColumnDescriptor> descriptors= registry.getColumnDescriptors();
+ for (Iterator<RulerColumnDescriptor> it= descriptors.iterator(); it.hasNext();) {
+ final RulerColumnDescriptor descriptor= it.next();
support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor));
}
}
@@ -3277,7 +3277,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (dndService == null)
return;
- ITextEditorDropTargetListener listener= (ITextEditorDropTargetListener) getAdapter(ITextEditorDropTargetListener.class);
+ ITextEditorDropTargetListener listener= getAdapter(ITextEditorDropTargetListener.class);
if (listener == null) {
Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$
@@ -3552,7 +3552,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (fTextDragAndDropToken == null) {
// Move in same editor - end compound change
- IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
+ IRewriteTarget target= getAdapter(IRewriteTarget.class);
if (target != null)
target.endCompoundChange();
}
@@ -3614,7 +3614,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
// Start compound change
- IRewriteTarget target= (IRewriteTarget)getAdapter(IRewriteTarget.class);
+ IRewriteTarget target= getAdapter(IRewriteTarget.class);
if (target != null)
target.beginCompoundChange();
}
@@ -4197,7 +4197,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (fIsOverwriting)
toggleOverwriteMode();
- setInsertMode((InsertMode) getLegalInsertModes().get(0));
+ setInsertMode(getLegalInsertModes().get(0));
updateCaret();
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
@@ -4592,7 +4592,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
- IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class);
+ IColumnSupport support= getAdapter(IColumnSupport.class);
for (int i= 0; i < difference.length; i++) {
RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
if (desc != null && support.isColumnSupported(desc)) {
@@ -5195,7 +5195,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
public void setAction(String actionID, IAction action) {
Assert.isNotNull(actionID);
if (action == null) {
- action= (IAction) fActions.remove(actionID);
+ action= fActions.remove(actionID);
if (action != null)
fActivationCodeTrigger.unregisterActionFromKeyActivation(action);
} else {
@@ -5221,18 +5221,18 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
private void setActionActivation(boolean state) {
if (state) {
fActivationCodeTrigger.install();
- Iterator iter= fActions.values().iterator();
+ Iterator<IAction> iter= fActions.values().iterator();
while (iter.hasNext()) {
- IAction action= (IAction)iter.next();
+ IAction action= iter.next();
if (action != null)
fActivationCodeTrigger.registerActionForKeyActivation(action);
}
getEditorSite().getActionBarContributor().setActiveEditor(this);
} else {
getEditorSite().getActionBarContributor().setActiveEditor(null);
- Iterator iter= fActions.values().iterator();
+ Iterator<IAction> iter= fActions.values().iterator();
while (iter.hasNext()) {
- IAction action= (IAction)iter.next();
+ IAction action= iter.next();
if (action != null)
fActivationCodeTrigger.unregisterActionFromKeyActivation(action);
}
@@ -5271,7 +5271,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
private ActionActivationCode findActionActivationCode(String actionID) {
int size= fActivationCodes.size();
for (int i= 0; i < size; i++) {
- ActionActivationCode code= (ActionActivationCode) fActivationCodes.get(i);
+ ActionActivationCode code= fActivationCodes.get(i);
if (actionID.equals(code.fActionId))
return code;
}
@@ -5289,7 +5289,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public IAction getAction(String actionID) {
Assert.isNotNull(actionID);
- IAction action= (IAction) fActions.get(actionID);
+ IAction action= fActions.get(actionID);
if (action == null) {
action= findContributedAction(actionID);
@@ -5309,7 +5309,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 2.0
*/
private IAction findContributedAction(String actionID) {
- List actions= new ArrayList();
+ List<IConfigurationElement> actions= new ArrayList<>();
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); //$NON-NLS-1$
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
@@ -5329,7 +5329,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (actionSize > 0) {
IConfigurationElement element;
if (actionSize > 1) {
- IConfigurationElement[] actionArray= (IConfigurationElement[])actions.toArray(new IConfigurationElement[actionSize]);
+ IConfigurationElement[] actionArray= actions.toArray(new IConfigurationElement[actionSize]);
ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
@Override
public IConfigurationElement getConfigurationElement(Object object) {
@@ -5339,7 +5339,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
sorter.sort(actionArray);
element= actionArray[0];
} else
- element= (IConfigurationElement)actions.get(0);
+ element= actions.get(0);
try {
return new ContributedAction(getSite(), element);
@@ -5360,7 +5360,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
private void updateAction(String actionId) {
Assert.isNotNull(actionId);
if (fActions != null) {
- IAction action= (IAction) fActions.get(actionId);
+ IAction action= fActions.get(actionId);
if (action instanceof IUpdate)
((IUpdate) action).update();
}
@@ -5433,9 +5433,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected void updateSelectionDependentActions() {
if (fSelectionActions != null) {
- Iterator e= fSelectionActions.iterator();
+ Iterator<String> e= fSelectionActions.iterator();
while (e.hasNext())
- updateAction((String) e.next());
+ updateAction(e.next());
}
}
@@ -5444,9 +5444,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected void updateContentDependentActions() {
if (fContentActions != null) {
- Iterator e= fContentActions.iterator();
+ Iterator<String> e= fContentActions.iterator();
while (e.hasNext())
- updateAction((String) e.next());
+ updateAction(e.next());
}
}
@@ -5456,9 +5456,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected void updatePropertyDependentActions() {
if (fPropertyActions != null) {
- Iterator e= fPropertyActions.iterator();
+ Iterator<String> e= fPropertyActions.iterator();
while (e.hasNext())
- updateAction((String) e.next());
+ updateAction(e.next());
}
}
@@ -5468,9 +5468,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected void updateStateDependentActions() {
if (fStateActions != null) {
- Iterator e= fStateActions.iterator();
+ Iterator<String> e= fStateActions.iterator();
while (e.hasNext())
- updateAction((String) e.next());
+ updateAction(e.next());
}
}
@@ -6046,8 +6046,8 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- for (Iterator i= fRulerContextMenuListeners.iterator(); i.hasNext();)
- ((IMenuListener) i.next()).menuAboutToShow(menu);
+ for (Iterator<IMenuListener> i= fRulerContextMenuListeners.iterator(); i.hasNext();)
+ i.next().menuAboutToShow(menu);
addAction(menu, ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS);
addAction(menu, ITextEditorActionConstants.RULER_MANAGE_TASKS);
@@ -6097,8 +6097,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
return getEditorSite().getActionBars().getStatusLineManager();
}
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class required) {
+ public <T> T getAdapter(Class<T> required) {
if (IEditorStatusLine.class.equals(required)) {
if (fEditorStatusLine == null) {
@@ -6107,12 +6108,12 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (statusLineManager != null && selectionProvider != null)
fEditorStatusLine= new EditorStatusLine(statusLineManager, selectionProvider);
}
- return fEditorStatusLine;
+ return (T) fEditorStatusLine;
}
if (IVerticalRulerInfo.class.equals(required)) {
if (fVerticalRuler != null)
- return fVerticalRuler;
+ return (T) fVerticalRuler;
}
if (IMarkRegionTarget.class.equals(required)) {
@@ -6121,14 +6122,14 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (manager != null)
fMarkRegionTarget= (fSourceViewer == null ? null : new MarkRegionTarget(fSourceViewer, manager));
}
- return fMarkRegionTarget;
+ return (T) fMarkRegionTarget;
}
if (IDeleteLineTarget.class.equals(required)) {
if (fDeleteLineTarget == null) {
fDeleteLineTarget= new TextViewerDeleteLineTarget(fSourceViewer);
}
- return fDeleteLineTarget;
+ return (T) fDeleteLineTarget;
}
if (IncrementalFindTarget.class.equals(required)) {
@@ -6137,7 +6138,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (manager != null)
fIncrementalFindTarget= (fSourceViewer == null ? null : new IncrementalFindTarget(fSourceViewer, manager));
}
- return fIncrementalFindTarget;
+ return (T) fIncrementalFindTarget;
}
if (IFindReplaceTarget.class.equals(required)) {
@@ -6149,27 +6150,27 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
fFindReplaceTarget.setScopeHighlightColor(fFindScopeHighlightColor);
}
}
- return fFindReplaceTarget;
+ return (T) fFindReplaceTarget;
}
if (ITextOperationTarget.class.equals(required))
- return (fSourceViewer == null ? null : fSourceViewer.getTextOperationTarget());
+ return (fSourceViewer == null ? null : (T) fSourceViewer.getTextOperationTarget());
if (IRewriteTarget.class.equals(required)) {
if (fSourceViewer instanceof ITextViewerExtension) {
ITextViewerExtension extension= (ITextViewerExtension) fSourceViewer;
- return extension.getRewriteTarget();
+ return (T) extension.getRewriteTarget();
}
return null;
}
if (Control.class.equals(required))
- return fSourceViewer != null ? fSourceViewer.getTextWidget() : null;
+ return fSourceViewer != null ? (T) fSourceViewer.getTextWidget() : null;
if (IColumnSupport.class.equals(required)) {
if (fColumnSupport == null)
fColumnSupport= createColumnSupport();
- return fColumnSupport;
+ return (T) fColumnSupport;
}
return super.getAdapter(required);
@@ -6342,7 +6343,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
if (field != null) {
if (fStatusFields == null)
- fStatusFields= new HashMap(3);
+ fStatusFields= new HashMap<>(3);
fStatusFields.put(category, field);
updateStatusField(category);
@@ -6363,7 +6364,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected IStatusField getStatusField(String category) {
if (category != null && fStatusFields != null)
- return (IStatusField) fStatusFields.get(category);
+ return fStatusFields.get(category);
return null;
}
@@ -6384,7 +6385,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
@Override
public void setInsertMode(InsertMode newMode) {
- List legalModes= getLegalInsertModes();
+ List<InsertMode> legalModes= getLegalInsertModes();
if (!legalModes.contains(newMode))
throw new IllegalArgumentException();
@@ -6400,9 +6401,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @return the set of legal insert modes
* @since 3.0
*/
- protected List getLegalInsertModes() {
+ protected List<InsertMode> getLegalInsertModes() {
if (fLegalInsertModes == null) {
- fLegalInsertModes= new ArrayList();
+ fLegalInsertModes= new ArrayList<>();
fLegalInsertModes.add(SMART_INSERT);
fLegalInsertModes.add(INSERT);
}
@@ -6412,7 +6413,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
private void switchToNextInsertMode() {
InsertMode mode= getInsertMode();
- List legalModes= getLegalInsertModes();
+ List<InsertMode> legalModes= getLegalInsertModes();
int i= 0;
while (i < legalModes.size()) {
@@ -6421,7 +6422,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
}
i= (i + 1) % legalModes.size();
- InsertMode newMode= (InsertMode) legalModes.get(i);
+ InsertMode newMode= legalModes.get(i);
setInsertMode(newMode);
}
@@ -6442,7 +6443,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 3.0
*/
protected void configureInsertMode(InsertMode mode, boolean legal) {
- List legalModes= getLegalInsertModes();
+ List<InsertMode> legalModes= getLegalInsertModes();
if (legal) {
if (!legalModes.contains(mode))
legalModes.add(mode);
@@ -6663,9 +6664,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*/
protected void updateStatusFields() {
if (fStatusFields != null) {
- Iterator e= fStatusFields.keySet().iterator();
+ Iterator<String> e= fStatusFields.keySet().iterator();
while (e.hasNext())
- updateStatusField((String) e.next());
+ updateStatusField(e.next());
}
}
@@ -6839,7 +6840,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 3.2
*/
protected void setStatusLineErrorMessage(String message) {
- IEditorStatusLine statusLine= (IEditorStatusLine)getAdapter(IEditorStatusLine.class);
+ IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(true, message, null);
}
@@ -6851,7 +6852,7 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
* @since 3.2
*/
protected void setStatusLineMessage(String message) {
- IEditorStatusLine statusLine= (IEditorStatusLine)getAdapter(IEditorStatusLine.class);
+ IEditorStatusLine statusLine= getAdapter(IEditorStatusLine.class);
if (statusLine != null)
statusLine.setMessage(false, message, null);
}
@@ -6905,9 +6906,9 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
int distance= Integer.MAX_VALUE;
IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (!isNavigationTarget(a))
continue;
@@ -7150,15 +7151,16 @@ public abstract class AbstractTextEditor extends EditorPart implements ITextEdit
*
* @see org.eclipse.ui.Saveable#getAdapter(java.lang.Class)
*/
+ @SuppressWarnings("unchecked")
@Override
- public Object getAdapter(Class adapter) {
+ public <T> T getAdapter(Class<T> adapter) {
if (adapter == IDocument.class) {
if (fDocument == null) {
IDocumentProvider documentProvider= fTextEditor.getDocumentProvider();
if (documentProvider != null)
fDocument= documentProvider.getDocument(fEditorInput);
}
- return fDocument;
+ return (T) fDocument;
}
return super.getAdapter(adapter);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
index 7f57fbad566..96183bb9ccf 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
@@ -317,7 +317,7 @@ public class AnnotationPreference {
* The map of attributes.
* @since 3.0
*/
- private Map fAttributes= new HashMap();
+ private Map<Object, Object> fAttributes= new HashMap<>();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
index 29acfb5422c..0e178ecf129 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
@@ -31,7 +31,6 @@ import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.part.EditorActionBarContributor;
-
/**
* Manages the installation and removal of global actions for
* the same type of editors.
@@ -136,7 +135,7 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
* The map of status fields.
* @since 2.0
*/
- private Map fStatusFields;
+ private Map<StatusFieldDef, StatusLineContributionItem> fStatusFields;
/**
@@ -160,7 +159,7 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
fHippieCompletion= new RetargetTextEditorAction(EditorMessages.getBundleForConstructedKeys(), "Editor.HippieCompletion."); //$NON-NLS-1$
fHippieCompletion.setActionDefinitionId(ITextEditorActionDefinitionIds.HIPPIE_COMPLETION);
- fStatusFields= new HashMap(3);
+ fStatusFields= new HashMap<>(3);
for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
StatusFieldDef fieldDef= STATUS_FIELD_DEFS[i];
fStatusFields.put(fieldDef, new StatusLineContributionItem(fieldDef.category, fieldDef.visible, fieldDef.widthInChars));
@@ -226,7 +225,7 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
if (fActiveEditorPart instanceof ITextEditorExtension) {
- StatusLineContributionItem statusField= (StatusLineContributionItem) fStatusFields.get(STATUS_FIELD_DEFS[i]);
+ StatusLineContributionItem statusField= fStatusFields.get(STATUS_FIELD_DEFS[i]);
statusField.setActionHandler(getAction(editor, STATUS_FIELD_DEFS[i].actionId));
ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category);
@@ -296,7 +295,7 @@ public class BasicTextEditorActionContributor extends EditorActionBarContributor
public void contributeToStatusLine(IStatusLineManager statusLineManager) {
super.contributeToStatusLine(statusLineManager);
for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
- statusLineManager.add((IContributionItem)fStatusFields.get(STATUS_FIELD_DEFS[i]));
+ statusLineManager.add(fStatusFields.get(STATUS_FIELD_DEFS[i]));
}
@Override
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java
index 528157f8a60..c6839b2de92 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.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
@@ -19,6 +19,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.osgi.framework.Bundle;
@@ -69,10 +70,10 @@ public abstract class ConfigurationElementSorter {
* Compare configuration elements according to the prerequisite relation
* of their defining plug-ins.
*/
- private class ConfigurationElementComparator implements Comparator {
+ private class ConfigurationElementComparator implements Comparator<Object> {
- private Map fDescriptorMapping;
- private Map fPrereqsMapping;
+ private Map<Object, String> fDescriptorMapping;
+ private Map<String, Set<String>> fPrereqsMapping;
public ConfigurationElementComparator(Object[] elements) {
Assert.isNotNull(elements);
@@ -104,14 +105,14 @@ public abstract class ConfigurationElementSorter {
if (element0 == null || element1 == null)
return false;
- String pluginDesc0= (String)fDescriptorMapping.get(element0);
- String pluginDesc1= (String)fDescriptorMapping.get(element1);
+ String pluginDesc0= fDescriptorMapping.get(element0);
+ String pluginDesc1= fDescriptorMapping.get(element1);
// performance tuning - code below would give same result
if (pluginDesc0.equals(pluginDesc1))
return false;
- Set prereqUIds0= (Set)fPrereqsMapping.get(pluginDesc0);
+ Set<String> prereqUIds0= fPrereqsMapping.get(pluginDesc0);
return prereqUIds0.contains(pluginDesc1);
}
@@ -123,9 +124,9 @@ public abstract class ConfigurationElementSorter {
*/
private void initialize(Object[] elements) {
int length= elements.length;
- fDescriptorMapping= new HashMap(length);
- fPrereqsMapping= new HashMap(length);
- Set fBundleSet= new HashSet(length);
+ fDescriptorMapping= new HashMap<>(length);
+ fPrereqsMapping= new HashMap<>(length);
+ Set<Bundle> fBundleSet= new HashSet<>(length);
for (int i= 0; i < length; i++) {
IConfigurationElement configElement= getConfigurationElement(elements[i]);
@@ -134,12 +135,12 @@ public abstract class ConfigurationElementSorter {
fBundleSet.add(bundle);
}
- Iterator iter= fBundleSet.iterator();
+ Iterator<Bundle> iter= fBundleSet.iterator();
while (iter.hasNext()) {
- Bundle bundle= (Bundle)iter.next();
- List toTest= new ArrayList(fBundleSet);
+ Bundle bundle= iter.next();
+ List<Bundle> toTest= new ArrayList<>(fBundleSet);
toTest.remove(bundle);
- Set prereqUIds= new HashSet(Math.max(0, toTest.size() - 1));
+ Set<String> prereqUIds= new HashSet<>(Math.max(0, toTest.size() - 1));
fPrereqsMapping.put(bundle.getSymbolicName(), prereqUIds);
String requires = bundle.getHeaders().get(Constants.REQUIRE_BUNDLE);
@@ -161,7 +162,7 @@ public abstract class ConfigurationElementSorter {
while (i < manifestElements.length && !toTest.isEmpty()) {
String prereqUId= manifestElements[i].getValue();
for (int j= 0; j < toTest.size();) {
- Bundle toTest_j= (Bundle)toTest.get(j);
+ Bundle toTest_j= toTest.get(j);
if (toTest_j.getSymbolicName().equals(prereqUId)) {
toTest.remove(toTest_j);
prereqUIds.add(toTest_j.getSymbolicName());
@@ -185,10 +186,10 @@ public abstract class ConfigurationElementSorter {
if (bundle != null) {
String bundleName= bundle.getSymbolicName();
if (bundleName != null) {
- Set entries= fDescriptorMapping.entrySet();
- Iterator iter= entries.iterator();
+ Set<Entry<Object, String>> entries= fDescriptorMapping.entrySet();
+ Iterator<Entry<Object, String>> iter= entries.iterator();
while (iter.hasNext()) {
- Map.Entry entry= (Map.Entry)iter.next();
+ Entry<Object, String> entry= iter.next();
if (bundleName.equals(entry.getValue())) {
IExtension extension = getConfigurationElement(entry.getKey()).getDeclaringExtension();
return extension.getExtensionPointUniqueIdentifier();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
index 526f9714165..1aff469ad87 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
@@ -28,6 +28,7 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.TextUtilities;
@@ -147,7 +148,7 @@ public class ConvertLineDelimitersAction extends TextEditorAction {
fRewriteTarget.setRedraw(false);
fRewriteTarget.beginCompoundChange();
- Map partitioners= TextUtilities.removeDocumentPartitioners(document);
+ Map<String, IDocumentPartitioner> partitioners= TextUtilities.removeDocumentPartitioners(document);
try {
for (int i= 0; i < lineCount; i++) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
index d72befd6911..82b678c8d54 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
@@ -55,7 +55,7 @@ public class FindNextAction extends ResourceAction implements IUpdate {
/** The dialog settings to retrieve the last search */
private IDialogSettings fDialogSettings;
/** The find history as initially given in the dialog settings. */
- private List fFindHistory= new ArrayList();
+ private List<String> fFindHistory= new ArrayList<>();
/** The find string as initially given in the dialog settings. */
private String fFindString;
/** The search direction as initially given in the dialog settings. */
@@ -130,7 +130,7 @@ public class FindNextAction extends ResourceAction implements IUpdate {
String fullSelection= fTarget.getSelectionText();
String firstLine= getFirstLine(fullSelection);
if ((firstLine.length() == 0 || fRegExSearch && fullSelection.equals(fSelection)) && !fFindHistory.isEmpty())
- return (String) fFindHistory.get(0);
+ return fFindHistory.get(0);
else if (fRegExSearch && fullSelection.length() > 0)
return FindReplaceDocumentAdapter.escapeForRegExPattern(fullSelection);
else
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java
index c8c8ff4d5b8..f2099d0603d 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java
@@ -111,7 +111,7 @@ public class FindReplaceAction extends ResourceAction implements IUpdate {
}
private void partActivated(IWorkbenchPart part) {
- IFindReplaceTarget target= part == null ? null : (IFindReplaceTarget) part.getAdapter(IFindReplaceTarget.class);
+ IFindReplaceTarget target= part == null ? null : part.getAdapter(IFindReplaceTarget.class);
fPreviousPart= fPart;
fPart= target == null ? null : part;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
index ccb9e673787..757d37af271 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
@@ -166,8 +166,8 @@ class FindReplaceDialog extends Dialog {
*/
boolean fIsRegExInit;
- private List fFindHistory;
- private List fReplaceHistory;
+ private List<String> fFindHistory;
+ private List<String> fReplaceHistory;
private IRegion fOldScope;
private boolean fIsTargetEditable;
@@ -222,7 +222,7 @@ class FindReplaceDialog extends Dialog {
* Holds the mnemonic/button pairs for all buttons.
* @since 3.7
*/
- private HashMap fMnemonicButtonMap= new HashMap();
+ private HashMap<Character, Button> fMnemonicButtonMap= new HashMap<>();
/**
@@ -236,8 +236,8 @@ class FindReplaceDialog extends Dialog {
fTarget= null;
fDialogPositionInit= null;
- fFindHistory= new ArrayList(HISTORY_SIZE - 1);
- fReplaceHistory= new ArrayList(HISTORY_SIZE - 1);
+ fFindHistory= new ArrayList<>(HISTORY_SIZE - 1);
+ fReplaceHistory= new ArrayList<>(HISTORY_SIZE - 1);
fWrapInit= false;
fCaseInit= false;
@@ -438,7 +438,7 @@ class FindReplaceDialog extends Dialog {
else if (e.detail == SWT.TRAVERSE_MNEMONIC) {
Character mnemonic= new Character(Character.toLowerCase(e.character));
if (fMnemonicButtonMap.containsKey(mnemonic)) {
- Button button= (Button)fMnemonicButtonMap.get(mnemonic);
+ Button button= fMnemonicButtonMap.get(mnemonic);
if ((fFindField.isFocusControl() || fReplaceField.isFocusControl() || (button.getStyle() & SWT.PUSH) != 0)
&& button.isEnabled()) {
Event event= new Event();
@@ -985,7 +985,7 @@ class FindReplaceDialog extends Dialog {
* Returns the dialog's history.
* @return the dialog's history
*/
- private List getFindHistory() {
+ private List<String> getFindHistory() {
return fFindHistory;
}
@@ -1006,7 +1006,7 @@ class FindReplaceDialog extends Dialog {
* Returns the dialog's replace history.
* @return the dialog's replace history
*/
- private List getReplaceHistory() {
+ private List<String> getReplaceHistory() {
return fReplaceHistory;
}
@@ -1130,7 +1130,7 @@ class FindReplaceDialog extends Dialog {
} else {
if ("".equals(fFindField.getText())) { //$NON-NLS-1$
if (fFindHistory.size() > 0)
- fFindField.setText((String) fFindHistory.get(0));
+ fFindField.setText(fFindHistory.get(0));
else
fFindField.setText(""); //$NON-NLS-1$
}
@@ -1628,7 +1628,7 @@ class FindReplaceDialog extends Dialog {
* @param combo combo to be updated
* @param content to be put into the combo
*/
- private void updateCombo(Combo combo, List content) {
+ private void updateCombo(Combo combo, List<String> content) {
combo.removeAll();
for (int i= 0; i < content.size(); i++) {
combo.add(content.get(i).toString());
@@ -1669,7 +1669,7 @@ class FindReplaceDialog extends Dialog {
* @param combo to be updated
* @param history to be put into the combo
*/
- private void updateHistory(Combo combo, List history) {
+ private void updateHistory(Combo combo, List<String> history) {
String findString= combo.getText();
int index= history.indexOf(findString);
if (index != 0) {
@@ -1812,7 +1812,7 @@ class FindReplaceDialog extends Dialog {
String[] findHistory= s.getArray("findhistory"); //$NON-NLS-1$
if (findHistory != null) {
- List history= getFindHistory();
+ List<String> history= getFindHistory();
history.clear();
for (int i= 0; i < findHistory.length; i++)
history.add(findHistory[i]);
@@ -1820,7 +1820,7 @@ class FindReplaceDialog extends Dialog {
String[] replaceHistory= s.getArray("replacehistory"); //$NON-NLS-1$
if (replaceHistory != null) {
- List history= getReplaceHistory();
+ List<String> history= getReplaceHistory();
history.clear();
for (int i= 0; i < replaceHistory.length; i++)
history.add(replaceHistory[i]);
@@ -1839,7 +1839,7 @@ class FindReplaceDialog extends Dialog {
s.put("incremental", fIncrementalInit); //$NON-NLS-1$
s.put("isRegEx", fIsRegExInit); //$NON-NLS-1$
- List history= getFindHistory();
+ List<String> history= getFindHistory();
String findString= getFindString();
if (findString.length() > 0)
history.add(0, findString);
@@ -1860,11 +1860,11 @@ class FindReplaceDialog extends Dialog {
* @param sectionName the section name
* @since 3.2
*/
- private void writeHistory(List history, IDialogSettings settings, String sectionName) {
+ private void writeHistory(List<String> history, IDialogSettings settings, String sectionName) {
int itemCount= history.size();
- Set distinctItems= new HashSet(itemCount);
+ Set<String> distinctItems= new HashSet<>(itemCount);
for (int i= 0; i < itemCount; i++) {
- String item= (String)history.get(i);
+ String item= history.get(i);
if (distinctItems.contains(item)) {
history.remove(i--);
itemCount--;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
index dc9abcd00ca..fdac907f881 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 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
@@ -67,14 +67,14 @@ final class HippieCompleteAction extends TextEditorAction {
*
* @since 3.6
*/
- private final Iterator suggestions;
+ private final Iterator<String> suggestions;
/**
* List of Strings with the suggestions that are already consumed from the iterator
*
* @since 3.6
*/
- private final List consumedSuggestions;
+ private final List<String> consumedSuggestions;
/**
* Do we have only 1 (empty) completion available?
@@ -88,7 +88,7 @@ final class HippieCompleteAction extends TextEditorAction {
*
* @since 3.6
*/
- private final HashSet alreadyFound;
+ private final HashSet<String> alreadyFound;
/**
* Create a new completion state object
@@ -97,10 +97,10 @@ final class HippieCompleteAction extends TextEditorAction {
* @param startOffset the position in the parent document at which the completions will be
* inserted.
*/
- CompletionState(Iterator suggestions, int startOffset) {
+ CompletionState(Iterator<String> suggestions, int startOffset) {
this.suggestions= suggestions;
- this.consumedSuggestions= new ArrayList();
- this.alreadyFound= new HashSet();
+ this.consumedSuggestions= new ArrayList<>();
+ this.alreadyFound= new HashSet<>();
this.startOffset= startOffset;
this.length= 0;
this.nextSuggestion= 0;
@@ -108,7 +108,7 @@ final class HippieCompleteAction extends TextEditorAction {
//Let's see if only 1 is available.
if (this.suggestions.hasNext()) {
- addNewToken((String)this.suggestions.next());
+ addNewToken(this.suggestions.next());
boolean hasOnly1Temp= true;
while (this.suggestions.hasNext()) {
@@ -137,7 +137,7 @@ final class HippieCompleteAction extends TextEditorAction {
String ret= null;
if (this.consumedSuggestions.size() > nextSuggestion) {
//We already consumed one that we didn't return
- ret= (String)this.consumedSuggestions.get(nextSuggestion);
+ ret= this.consumedSuggestions.get(nextSuggestion);
nextSuggestion++;
}
@@ -146,7 +146,7 @@ final class HippieCompleteAction extends TextEditorAction {
this.consumedSuggestions.size() == nextSuggestion &&
this.suggestions.hasNext()) {
//we're just in the place to get a new one from the iterator
- String temp= (String)this.suggestions.next();
+ String temp= this.suggestions.next();
if (this.alreadyFound.contains(temp)) {
continue;//go to next iteration
}
@@ -158,7 +158,7 @@ final class HippieCompleteAction extends TextEditorAction {
if (ret == null) {
//we consumed all in the iterator, so, just start cycling.
- ret= (String)this.consumedSuggestions.get(0);
+ ret= this.consumedSuggestions.get(0);
nextSuggestion= 1; //we just got the 0, so, we can already skip to 1.
}
@@ -359,12 +359,12 @@ final class HippieCompleteAction extends TextEditorAction {
clearState();
- List documents= HippieCompletionEngine.computeDocuments(getTextEditor());
+ List<IDocument> documents= HippieCompletionEngine.computeDocuments(getTextEditor());
if (documents.size() > 0) {
- fDocument= (IDocument)documents.remove(0);
+ fDocument= documents.remove(0);
- Iterator suggestions;
+ Iterator<String> suggestions;
try {
String prefix= getCurrentPrefix();
if (prefix == null) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
index afc6350bcfa..0e410a74739 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -180,16 +180,16 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
if (prefix == null || prefix.length() == 0)
return NO_PROPOSALS;
- List suggestions= getSuggestions(viewer, offset, prefix);
+ List<String> suggestions= getSuggestions(viewer, offset, prefix);
- List result= new ArrayList();
- for (Iterator it= suggestions.iterator(); it.hasNext();) {
- String string= (String) it.next();
+ List<ICompletionProposal> result= new ArrayList<>();
+ for (Iterator<String> it= suggestions.iterator(); it.hasNext();) {
+ String string= it.next();
if (string.length() > 0)
result.add(createProposal(string, prefix, offset));
}
- return (ICompletionProposal[]) result.toArray(new ICompletionProposal[result.size()]);
+ return result.toArray(new ICompletionProposal[result.size()]);
} catch (BadLocationException x) {
// ignore and return no proposals
@@ -244,9 +244,9 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
* @return all possible completions that were found in the current document
* @throws BadLocationException if accessing the document fails
*/
- private ArrayList createSuggestionsFromOpenDocument(ITextViewer viewer, int offset, String prefix) throws BadLocationException {
+ private ArrayList<String> createSuggestionsFromOpenDocument(ITextViewer viewer, int offset, String prefix) throws BadLocationException {
IDocument document= viewer.getDocument();
- ArrayList completions= new ArrayList();
+ ArrayList<String> completions= new ArrayList<>();
completions.addAll(fEngine.getCompletionsBackwards(document, prefix, offset));
completions.addAll(fEngine.getCompletionsForward(document, prefix, offset - prefix.length(), true));
@@ -263,9 +263,9 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
* @return the list of all possible suggestions in the currently open editors
* @throws BadLocationException if accessing the current document fails
*/
- private List getSuggestions(ITextViewer viewer, int offset, String prefix) throws BadLocationException {
+ private List<String> getSuggestions(ITextViewer viewer, int offset, String prefix) throws BadLocationException {
- ArrayList suggestions= createSuggestionsFromOpenDocument(viewer, offset, prefix);
+ ArrayList<String> suggestions= createSuggestionsFromOpenDocument(viewer, offset, prefix);
IDocument currentDocument= viewer.getDocument();
IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
@@ -284,7 +284,7 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
// add the empty suggestion
suggestions.add(""); //$NON-NLS-1$
- List uniqueSuggestions= fEngine.makeUnique(suggestions);
+ List<String> uniqueSuggestions= fEngine.makeUnique(suggestions);
return uniqueSuggestions;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
index 8d1aedce284..37f2c025c2c 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorDescriptor.java
@@ -221,7 +221,7 @@ public final class HyperlinkDetectorDescriptor {
private static HyperlinkDetectorDescriptor[] createDescriptors(IConfigurationElement[] elements) {
HyperlinkDetectorTargetDescriptor[] targets= HyperlinkDetectorTargetDescriptor.getContributedHyperlinkDetectorTargets();
- List result= new ArrayList(elements.length);
+ List<HyperlinkDetectorDescriptor> result= new ArrayList<>(elements.length);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (HYPERLINK_DETECTOR_ELEMENT.equals(element.getName())) {
@@ -237,7 +237,7 @@ public final class HyperlinkDetectorDescriptor {
TextEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, null));
}
}
- return (HyperlinkDetectorDescriptor[])result.toArray(new HyperlinkDetectorDescriptor[result.size()]);
+ return result.toArray(new HyperlinkDetectorDescriptor[result.size()]);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
index 0d67929896c..f38b02b48cb 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2013 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
@@ -158,7 +158,7 @@ public final class HyperlinkDetectorRegistry {
Assert.isLegal(targetId != null);
initHyperlinkDetectorDescriptors();
- List result= new ArrayList();
+ List<HyperlinkDetectorDelegate> result= new ArrayList<>();
for (int i= 0; i < fHyperlinkDetectorDescriptors.length; i++) {
if (targetId.equals(fHyperlinkDetectorDescriptors[i].getTargetId())) {
HyperlinkDetectorDelegate detector= new HyperlinkDetectorDelegate(fHyperlinkDetectorDescriptors[i]);
@@ -166,7 +166,7 @@ public final class HyperlinkDetectorRegistry {
detector.setContext(context);
}
}
- return (IHyperlinkDetector[])result.toArray(new IHyperlinkDetector[result.size()]);
+ return result.toArray(new IHyperlinkDetector[result.size()]);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java
index c0027e40210..b41e49a93db 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HyperlinkDetectorTargetDescriptor.java
@@ -123,7 +123,7 @@ public final class HyperlinkDetectorTargetDescriptor {
}
private static HyperlinkDetectorTargetDescriptor[] createDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(elements.length);
+ List<HyperlinkDetectorTargetDescriptor> result= new ArrayList<>(elements.length);
for (int i= 0; i < elements.length; i++) {
IConfigurationElement element= elements[i];
if (TARGET_ELEMENT.equals(element.getName())) {
@@ -140,7 +140,7 @@ public final class HyperlinkDetectorTargetDescriptor {
}
}
- return (HyperlinkDetectorTargetDescriptor[])result.toArray(new HyperlinkDetectorTargetDescriptor[result.size()]);
+ return result.toArray(new HyperlinkDetectorTargetDescriptor[result.size()]);
}
private boolean isValid() {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
index 818e5ae51ff..3b0b219927b 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.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
@@ -114,7 +114,7 @@ class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExt
*/
private boolean fSearching;
/** The current find stack */
- private Stack fSessionStack;
+ private Stack<SearchResult> fSessionStack;
/**
* The previous search string
* @since 2.1
@@ -182,7 +182,7 @@ class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExt
SearchResult searchResult= null;
if (!fSessionStack.empty())
- searchResult= (SearchResult) fSessionStack.pop();
+ searchResult= fSessionStack.pop();
if (searchResult == null) {
text.getDisplay().beep();
@@ -272,7 +272,7 @@ class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExt
}
fFindString.setLength(0);
- fSessionStack= new Stack();
+ fSessionStack= new Stack<>();
fCasePosition= -1;
fWrapPosition= -1;
fFound= true;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java
index 0ebdb6cf283..5ac90b26052 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/KeyBindingSupportForAssistant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 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
@@ -81,7 +81,7 @@ public final class KeyBindingSupportForAssistant implements ICompletionListener
}
- private List fReplacedCommands;
+ private List<ReplacedCommand> fReplacedCommands;
private ContentAssistantFacade fContentAssistantFacade;
private IQuickAssistAssistant fQuickAssistAssistant;
@@ -133,7 +133,7 @@ public final class KeyBindingSupportForAssistant implements ICompletionListener
public void assistSessionStarted(ContentAssistEvent event) {
ICommandService commandService= PlatformUI.getWorkbench().getService(ICommandService.class);
IHandler handler= getHandler(ContentAssistant.SELECT_NEXT_PROPOSAL_COMMAND_ID);
- fReplacedCommands= new ArrayList(10);
+ fReplacedCommands= new ArrayList<>(10);
fReplacedCommands.add(new ReplacedCommand(ITextEditorActionDefinitionIds.LINE_DOWN, handler, commandService));
handler= getHandler(ContentAssistant.SELECT_PREVIOUS_PROPOSAL_COMMAND_ID);
fReplacedCommands.add(new ReplacedCommand(ITextEditorActionDefinitionIds.LINE_UP, handler, commandService));
@@ -170,9 +170,9 @@ public final class KeyBindingSupportForAssistant implements ICompletionListener
if (fReplacedCommands == null)
return;
- Iterator iter= fReplacedCommands.iterator();
+ Iterator<ReplacedCommand> iter= fReplacedCommands.iterator();
while (iter.hasNext())
- ((ReplacedCommand)iter.next()).activate();
+ iter.next().activate();
fReplacedCommands= null;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
index b1b93af7f7a..a8ceb1c6c95 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java
@@ -220,7 +220,7 @@ public class SourceViewerDecorationSupport {
private ICharacterPairMatcher fCharacterPairMatcher;
/** Map with annotation type preference per annotation type */
- private Map fAnnotationTypeKeyMap= new LinkedHashMap();
+ private Map<Object, AnnotationPreference> fAnnotationTypeKeyMap= new LinkedHashMap<>();
/** Preference key for the cursor line highlighting */
private String fCursorLinePainterEnableKey;
/** Preference key for the cursor line background color */
@@ -311,7 +311,7 @@ public class SourceViewerDecorationSupport {
else
hideMargin();
- Iterator e= fAnnotationTypeKeyMap.keySet().iterator();
+ Iterator<Object> e= fAnnotationTypeKeyMap.keySet().iterator();
while (e.hasNext()) {
Object type= e.next();
if (areAnnotationsHighlighted(type) || areAnnotationsShown(type))
@@ -336,7 +336,7 @@ public class SourceViewerDecorationSupport {
return null;
if (areAnnotationsShown(annotationType) && fPreferenceStore != null) {
- AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null) {
String key= info.getTextStylePreferenceKey();
if (key != null)
@@ -353,7 +353,7 @@ public class SourceViewerDecorationSupport {
*/
public void updateOverviewDecorations() {
if (fOverviewRuler != null) {
- Iterator e= fAnnotationTypeKeyMap.keySet().iterator();
+ Iterator<Object> e= fAnnotationTypeKeyMap.keySet().iterator();
while (e.hasNext()) {
Object type= e.next();
if (isAnnotationOverviewShown(type))
@@ -510,9 +510,9 @@ public class SourceViewerDecorationSupport {
* @return the annotation preference
*/
private AnnotationPreference getAnnotationPreferenceInfo(String preferenceKey) {
- Iterator e= fAnnotationTypeKeyMap.values().iterator();
+ Iterator<AnnotationPreference> e= fAnnotationTypeKeyMap.values().iterator();
while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
+ AnnotationPreference info= e.next();
if (info != null && info.isPreferenceKey(preferenceKey))
return info;
}
@@ -664,7 +664,7 @@ public class SourceViewerDecorationSupport {
* @return the color of the annotation type
*/
private Color getAnnotationTypeColor(Object annotationType) {
- AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null)
return getColor( info.getColorPreferenceKey());
return null;
@@ -679,7 +679,7 @@ public class SourceViewerDecorationSupport {
* @return the layer
*/
private int getAnnotationTypeLayer(Object annotationType) {
- AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null)
return info.getPresentationLayer();
return 0;
@@ -938,7 +938,7 @@ public class SourceViewerDecorationSupport {
*/
private boolean areAnnotationsShown(Object annotationType) {
if (fPreferenceStore != null) {
- AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null) {
String key= info.getTextPreferenceKey();
return key != null && fPreferenceStore.getBoolean(key);
@@ -956,7 +956,7 @@ public class SourceViewerDecorationSupport {
*/
private boolean areAnnotationsHighlighted(Object annotationType) {
if (fPreferenceStore != null) {
- AnnotationPreference info= (AnnotationPreference)fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null)
return info.getHighlightPreferenceKey() != null && fPreferenceStore.getBoolean(info.getHighlightPreferenceKey());
}
@@ -971,7 +971,7 @@ public class SourceViewerDecorationSupport {
*/
private boolean isAnnotationOverviewShown(Object annotationType) {
if (fPreferenceStore != null && fOverviewRuler != null) {
- AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType);
+ AnnotationPreference info= fAnnotationTypeKeyMap.get(annotationType);
if (info != null)
return fPreferenceStore.getBoolean(info.getOverviewRulerPreferenceKey());
}
@@ -1012,7 +1012,7 @@ public class SourceViewerDecorationSupport {
*/
public void hideAnnotationOverview() {
if (fOverviewRuler != null) {
- Iterator e= fAnnotationTypeKeyMap.keySet().iterator();
+ Iterator<Object> e= fAnnotationTypeKeyMap.keySet().iterator();
while (e.hasNext())
fOverviewRuler.removeAnnotationType(e.next());
fOverviewRuler.update();
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
index 57146ee777c..cda9cfac1df 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.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
@@ -66,12 +66,12 @@ public class QuickDiff {
*
* @return the non-modifiable list of extensions to the <code>quickDiffReferenceProvider</code> extension point.
*/
- public List getReferenceProviderDescriptors() {
+ public List<ReferenceProviderDescriptor> getReferenceProviderDescriptors() {
QuickDiffExtensionsRegistry registry= TextEditorPlugin.getDefault().getQuickDiffExtensionRegistry();
if (registry != null)
return registry.getReferenceProviderDescriptors();
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
/**
@@ -91,10 +91,10 @@ public class QuickDiff {
Assert.isNotNull(editor);
Assert.isNotNull(id);
- List descs= getReferenceProviderDescriptors();
+ List<ReferenceProviderDescriptor> descs= getReferenceProviderDescriptors();
// try to fetch preferred provider; load if needed
- for (Iterator iter= descs.iterator(); iter.hasNext();) {
- ReferenceProviderDescriptor desc= (ReferenceProviderDescriptor) iter.next();
+ for (Iterator<ReferenceProviderDescriptor> iter= descs.iterator(); iter.hasNext();) {
+ ReferenceProviderDescriptor desc= iter.next();
if (desc.getId().equals(id)) {
IQuickDiffReferenceProvider provider= desc.createProvider();
if (provider != null) {
@@ -107,8 +107,8 @@ public class QuickDiff {
}
}
- for (ListIterator iter= descs.listIterator(descs.size()); iter.hasPrevious();) {
- ReferenceProviderDescriptor desc= (ReferenceProviderDescriptor) iter.previous();
+ for (ListIterator<ReferenceProviderDescriptor> iter= descs.listIterator(descs.size()); iter.hasPrevious();) {
+ ReferenceProviderDescriptor desc= iter.previous();
IQuickDiffReferenceProvider provider= desc.createProvider();
if (provider != null) {
provider.setActiveEditor(editor);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
index 21fc95c6201..3678d4d1350 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java
@@ -96,9 +96,9 @@ public class QuickDiffToggleAction implements IEditorActionDelegate, IUpdate {
// create quickdiff menu
menu= new MenuManager(QuickDiffMessages.quickdiff_menu_label, MENU_ID);
- List descriptors= new QuickDiff().getReferenceProviderDescriptors();
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- ReferenceProviderDescriptor desc= (ReferenceProviderDescriptor) it.next();
+ List<ReferenceProviderDescriptor> descriptors= new QuickDiff().getReferenceProviderDescriptors();
+ for (Iterator<ReferenceProviderDescriptor> it= descriptors.iterator(); it.hasNext();) {
+ ReferenceProviderDescriptor desc= it.next();
ReferenceSelectionAction action= new ReferenceSelectionAction(desc, fEditor);
if (action.isEnabled())
menu.add(action);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java
index 08a64d8cef3..acc93796617 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnPreferenceAdapter.java
@@ -64,7 +64,7 @@ public final class RulerColumnPreferenceAdapter {
Assert.isLegal(descriptor != null);
String id= descriptor.getId();
String preference= fStore.getString(fKey);
- Set marked= StringSetSerializer.deserialize(preference);
+ Set<String> marked= StringSetSerializer.deserialize(preference);
boolean shouldMark= enabled ^ descriptor.getDefaultEnablement();
boolean isMarked= marked.contains(id);
if (isMarked != shouldMark) {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java
index 1ee546c4c3d..9baa4e649c5 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/rulers/RulerColumnRegistry.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
@@ -73,14 +73,13 @@ public final class RulerColumnRegistry {
}
/**
- * All descriptors (element type:
- * {@link RulerColumnDescriptor}).
+ * All descriptors.
*/
- private List fDescriptors= null;
+ private List<RulerColumnDescriptor> fDescriptors= null;
/**
- * All descriptors by id (element type: {@link RulerColumnDescriptor}).
+ * All descriptors by id.
*/
- private Map fDescriptorMap= null;
+ private Map<String, RulerColumnDescriptor> fDescriptorMap= null;
/**
* <code>true</code> if this registry has been loaded.
@@ -103,9 +102,8 @@ public final class RulerColumnRegistry {
* </p>
*
* @return the sorted list of extensions to the <code>rulerColumns</code> extension point
- * (element type: {@link RulerColumnDescriptor})
*/
- public List getColumnDescriptors() {
+ public List<RulerColumnDescriptor> getColumnDescriptors() {
ensureExtensionPointRead();
return fDescriptors;
}
@@ -121,7 +119,7 @@ public final class RulerColumnRegistry {
public RulerColumnDescriptor getColumnDescriptor(String id) {
Assert.isLegal(id != null);
ensureExtensionPointRead();
- return (RulerColumnDescriptor) fDescriptorMap.get(id);
+ return fDescriptorMap.get(id);
}
/**
@@ -147,13 +145,13 @@ public final class RulerColumnRegistry {
*/
public void reload() {
IExtensionRegistry registry= Platform.getExtensionRegistry();
- List elements= new ArrayList(Arrays.asList(registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, EXTENSION_POINT)));
+ List<IConfigurationElement> elements= new ArrayList<>(Arrays.asList(registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, EXTENSION_POINT)));
- List descriptors= new ArrayList();
- Map descriptorMap= new HashMap();
+ List<RulerColumnDescriptor> descriptors= new ArrayList<>();
+ Map<String, RulerColumnDescriptor> descriptorMap= new HashMap<>();
- for (Iterator iter= elements.iterator(); iter.hasNext();) {
- IConfigurationElement element= (IConfigurationElement) iter.next();
+ for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) {
+ IConfigurationElement element= iter.next();
try {
RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this);
String id= desc.getId();
@@ -189,7 +187,7 @@ public final class RulerColumnRegistry {
*
* @param descriptors the descriptors to sort
*/
- private void sort(List descriptors) {
+ private void sort(List<RulerColumnDescriptor> descriptors) {
/*
* Topological sort of the DAG defined by the plug-in dependencies
* 1. TopoSort descriptors by plug-in dependency
@@ -202,25 +200,25 @@ public final class RulerColumnRegistry {
return ((RulerColumnDescriptor) object).getConfigurationElement();
}
};
- Object[] array= descriptors.toArray();
+ RulerColumnDescriptor[] array= descriptors.toArray(new RulerColumnDescriptor[descriptors.size()]);
sorter.sort(array);
- Map descriptorsById= new HashMap();
+ Map<String, RulerColumnDescriptor> descriptorsById= new HashMap<>();
for (int i= 0; i < array.length; i++) {
- RulerColumnDescriptor desc= (RulerColumnDescriptor) array[i];
+ RulerColumnDescriptor desc= array[i];
descriptorsById.put(desc.getId(), desc);
}
- DAG dag= new DAG();
+ DAG<RulerColumnDescriptor> dag= new DAG<>();
for (int i= 0; i < array.length; i++) {
- RulerColumnDescriptor desc= (RulerColumnDescriptor) array[i];
+ RulerColumnDescriptor desc= array[i];
dag.addVertex(desc);
- Set before= desc.getPlacement().getConstraints();
- for (Iterator it= before.iterator(); it.hasNext();) {
- RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next();
+ Set<RulerColumnPlacementConstraint> before= desc.getPlacement().getConstraints();
+ for (Iterator<RulerColumnPlacementConstraint> it= before.iterator(); it.hasNext();) {
+ RulerColumnPlacementConstraint constraint= it.next();
String id= constraint.getId();
- RulerColumnDescriptor target= (RulerColumnDescriptor) descriptorsById.get(id);
+ RulerColumnDescriptor target= descriptorsById.get(id);
if (target == null) {
noteUnknownTarget(desc, id);
} else {
@@ -235,10 +233,10 @@ public final class RulerColumnRegistry {
}
}
- Comparator gravityComp= new Comparator() {
+ Comparator<RulerColumnDescriptor> gravityComp= new Comparator<RulerColumnDescriptor>() {
@Override
- public int compare(Object o1, Object o2) {
- float diff= ((RulerColumnDescriptor) o1).getPlacement().getGravity() - ((RulerColumnDescriptor) o2).getPlacement().getGravity();
+ public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) {
+ float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity();
if (diff == 0)
return 0;
if (diff < 0)
@@ -248,10 +246,10 @@ public final class RulerColumnRegistry {
};
/* Topological sort - always select the source with the least gravity */
- Set toProcess= dag.getSources();
+ Set<RulerColumnDescriptor> toProcess= dag.getSources();
int index= 0;
while (!toProcess.isEmpty()) {
- Object next= Collections.min(toProcess, gravityComp);
+ RulerColumnDescriptor next= Collections.min(toProcess, gravityComp);
array[index]= next;
index++;
dag.removeVertex(next);
@@ -259,7 +257,7 @@ public final class RulerColumnRegistry {
}
Assert.isTrue(index == array.length);
- ListIterator it= descriptors.listIterator();
+ ListIterator<RulerColumnDescriptor> it= descriptors.listIterator();
for (int i= 0; i < index; i++) {
it.next();
it.set(array[i]);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
index 2b4f689f560..164377bd864 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingCorrectionProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
+ * Copyright (c) 2006, 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
@@ -55,23 +55,23 @@ public final class SpellingCorrectionProcessor implements IQuickAssistProcessor
if (model == null)
return fgNoSuggestionsProposal;
- List proposals= computeProposals(context, model);
+ List<ICompletionProposal> proposals= computeProposals(context, model);
if (proposals.isEmpty())
return fgNoSuggestionsProposal;
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+ return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
private boolean isAtPosition(int offset, Position pos) {
return (pos != null) && (offset >= pos.getOffset() && offset <= (pos.getOffset() + pos.getLength()));
}
- private List computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) {
+ private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, IAnnotationModel model) {
int offset= context.getOffset();
- ArrayList annotationList= new ArrayList();
- Iterator iter= model.getAnnotationIterator();
+ ArrayList<SpellingProblem> annotationList= new ArrayList<>();
+ Iterator<Annotation> iter= model.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation)iter.next();
+ Annotation annotation= iter.next();
if (canFix(annotation)) {
Position pos= model.getPosition(annotation);
if (isAtPosition(offset, pos)) {
@@ -79,17 +79,17 @@ public final class SpellingCorrectionProcessor implements IQuickAssistProcessor
}
}
}
- SpellingProblem[] spellingProblems= (SpellingProblem[]) annotationList.toArray(new SpellingProblem[annotationList.size()]);
+ SpellingProblem[] spellingProblems= annotationList.toArray(new SpellingProblem[annotationList.size()]);
return computeProposals(context, spellingProblems);
}
- private void collectSpellingProblems(Annotation annotation, List problems) {
+ private void collectSpellingProblems(Annotation annotation, List<SpellingProblem> problems) {
if (annotation instanceof SpellingAnnotation)
problems.add(((SpellingAnnotation)annotation).getSpellingProblem());
}
- private List computeProposals(IQuickAssistInvocationContext context, SpellingProblem[] spellingProblems) {
- List proposals= new ArrayList();
+ private List<ICompletionProposal> computeProposals(IQuickAssistInvocationContext context, SpellingProblem[] spellingProblems) {
+ List<ICompletionProposal> proposals= new ArrayList<>();
for (int i= 0; i < spellingProblems.length; i++)
proposals.addAll(Arrays.asList(spellingProblems[i].getProposals(context)));
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.java
index 5f7df930308..1e432e8d04f 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingProblem.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
@@ -83,10 +83,10 @@ public abstract class SpellingProblem {
return;
boolean supportsBatchReplace= (model instanceof IAnnotationModelExtension);
- List toBeRemovedAnnotations= new ArrayList();
- Iterator iter= model.getAnnotationIterator();
+ List<Annotation> toBeRemovedAnnotations= new ArrayList<>();
+ Iterator<Annotation> iter= model.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (SpellingAnnotation.TYPE.equals(annotation.getType())) {
boolean doRemove= word == null;
if (word == null)
@@ -111,7 +111,7 @@ public abstract class SpellingProblem {
}
if (supportsBatchReplace && !toBeRemovedAnnotations.isEmpty()) {
- Annotation[] annotationArray= (Annotation[])toBeRemovedAnnotations.toArray(new Annotation[toBeRemovedAnnotations.size()]);
+ Annotation[] annotationArray= toBeRemovedAnnotations.toArray(new Annotation[toBeRemovedAnnotations.size()]);
((IAnnotationModelExtension)model).replaceAnnotations(annotationArray, null);
}
}
@@ -136,10 +136,10 @@ public abstract class SpellingProblem {
return;
boolean supportsBatchReplace= (model instanceof IAnnotationModelExtension);
- List toBeRemovedAnnotations= new ArrayList();
- Iterator iter= model.getAnnotationIterator();
+ List<Annotation> toBeRemovedAnnotations= new ArrayList<>();
+ Iterator<Annotation> iter= model.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (SpellingAnnotation.TYPE.equals(annotation.getType())) {
boolean doRemove= word == null;
if (word == null)
@@ -164,7 +164,7 @@ public abstract class SpellingProblem {
}
if (supportsBatchReplace && !toBeRemovedAnnotations.isEmpty()) {
- Annotation[] annotationArray= (Annotation[])toBeRemovedAnnotations.toArray(new Annotation[toBeRemovedAnnotations.size()]);
+ Annotation[] annotationArray= toBeRemovedAnnotations.toArray(new Annotation[toBeRemovedAnnotations.size()]);
((IAnnotationModelExtension)model).replaceAnnotations(annotationArray, null);
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java
index d777e9ae0d6..92ec1cfe3d9 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/spelling/SpellingReconcileStrategy.java
@@ -54,7 +54,7 @@ public class SpellingReconcileStrategy implements IReconcilingStrategy, IReconci
private IAnnotationModel fAnnotationModel;
/** Annotations to add. */
- private Map fAddAnnotations;
+ private Map<Annotation, Position> fAddAnnotations;
/** Lock object for modifying the annotations. */
private Object fLockObject;
@@ -80,22 +80,22 @@ public class SpellingReconcileStrategy implements IReconcilingStrategy, IReconci
@Override
public void beginCollecting() {
- fAddAnnotations= new HashMap();
+ fAddAnnotations= new HashMap<>();
}
@Override
public void endCollecting() {
- List toRemove= new ArrayList();
+ List<Annotation> toRemove= new ArrayList<>();
synchronized (fLockObject) {
- Iterator iter= fAnnotationModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fAnnotationModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation)iter.next();
+ Annotation annotation= iter.next();
if (SpellingAnnotation.TYPE.equals(annotation.getType()))
toRemove.add(annotation);
}
- Annotation[] annotationsToRemove= (Annotation[])toRemove.toArray(new Annotation[toRemove.size()]);
+ Annotation[] annotationsToRemove= toRemove.toArray(new Annotation[toRemove.size()]);
if (fAnnotationModel instanceof IAnnotationModelExtension)
((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(annotationsToRemove, fAddAnnotations);
@@ -103,8 +103,8 @@ public class SpellingReconcileStrategy implements IReconcilingStrategy, IReconci
for (int i= 0; i < annotationsToRemove.length; i++)
fAnnotationModel.removeAnnotation(annotationsToRemove[i]);
for (iter= fAddAnnotations.keySet().iterator(); iter.hasNext();) {
- Annotation annotation= (Annotation)iter.next();
- fAnnotationModel.addAnnotation(annotation, (Position)fAddAnnotations.get(annotation));
+ Annotation annotation= iter.next();
+ fAnnotationModel.addAnnotation(annotation, fAddAnnotations.get(annotation));
}
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
index 7600c5ded4c..d873cc51c50 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/AbstractTemplatesPage.java
@@ -344,13 +344,13 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
}
private TemplatePersistenceData[] getTemplates(String contextId) {
- List templateList= new ArrayList();
+ List<TemplatePersistenceData> templateList= new ArrayList<>();
TemplatePersistenceData[] datas= getTemplateStore().getTemplateData(false);
for (int i= 0; i < datas.length; i++) {
if (datas[i].isEnabled() && datas[i].getTemplate().getContextTypeId().equals(contextId))
templateList.add(datas[i]);
}
- return (TemplatePersistenceData[]) templateList
+ return templateList
.toArray(new TemplatePersistenceData[templateList.size()]);
}
@@ -386,10 +386,10 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
@Override
public Object[] getElements(Object inputElement) {
- List contextTypes= new ArrayList();
+ List<TemplateContextType> contextTypes= new ArrayList<>();
- for (Iterator iterator= getContextTypeRegistry().contextTypes(); iterator.hasNext();) {
- TemplateContextType contextType= (TemplateContextType) iterator.next();
+ for (Iterator<TemplateContextType> iterator= getContextTypeRegistry().contextTypes(); iterator.hasNext();) {
+ TemplateContextType contextType= iterator.next();
if (!fLinkWithEditorAction.isChecked() || isActiveContext(contextType))
contextTypes.add(contextType);
}
@@ -435,7 +435,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
private Action fCopyAction;
/* Current active context types for the editor */
- private List fActiveTypes;
+ private List<String> fActiveTypes;
/* Preference stores */
private IPreferenceStore fPreferenceStore;
@@ -1198,7 +1198,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
private void setSelectedTemplates() {
IStructuredSelection selection= (IStructuredSelection) fTreeViewer.getSelection();
- Iterator it= selection.iterator();
+ Iterator<?> it= selection.iterator();
TemplatePersistenceData[] data= new TemplatePersistenceData[selection.size()];
int i= 0;
while (it.hasNext()) {
@@ -1247,7 +1247,7 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
Object item;
if (selection.size() == 0)
- return ((TemplateContextType) getContextTypeRegistry().contextTypes().next()).getId();
+ return getContextTypeRegistry().contextTypes().next().getId();
if (selection.size() == 1) {
item= selection.getFirstElement();
@@ -1255,14 +1255,14 @@ public abstract class AbstractTemplatesPage extends Page implements ITemplatesPa
return ((TemplatePersistenceData) item).getTemplate().getContextTypeId();
return ((TemplateContextType) item).getId();
}
- Iterator it= selection.iterator();
+ Iterator<?> it= selection.iterator();
String contextId= null;
while (it.hasNext()) {
item= it.next();
if (contextId == null)
contextId= getContextId(item);
else if (!contextId.equals(getContextId(item)))
- return ((TemplateContextType) getContextTypeRegistry().contextTypes().next())
+ return getContextTypeRegistry().contextTypes().next()
.getId();
}
return contextId;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java
index e8e3d64194c..f4075c9b01e 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/ColumnLayout.java
@@ -63,7 +63,7 @@ final class ColumnLayout extends Layout {
COLUMN_TRIM= 3;
}
- private List columns= new ArrayList();
+ private List<ColumnLayoutData> columns= new ArrayList<>();
/**
* Adds a new column of data to this table layout.
@@ -80,7 +80,7 @@ final class ColumnLayout extends Layout {
int width= 0;
int size= columns.size();
for (int i= 0; i < size; ++i) {
- ColumnLayoutData layoutData= (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData layoutData= columns.get(i);
if (layoutData instanceof ColumnPixelData) {
ColumnPixelData col= (ColumnPixelData) layoutData;
width += col.width;
@@ -113,7 +113,7 @@ final class ColumnLayout extends Layout {
// First calc space occupied by fixed columns
for (int i= 0; i < size; i++) {
- ColumnLayoutData col= (ColumnLayoutData) columns.get(i);
+ ColumnLayoutData col= columns.get(i);
if (col instanceof ColumnPixelData) {
ColumnPixelData cpd= (ColumnPixelData) col;
int pixels= cpd.width;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
index 6d3da8c01fb..56c34f9e740 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 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
@@ -128,6 +128,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchCommandConstants;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.texteditor.NLSUtility;
import org.eclipse.ui.internal.texteditor.SWTUtil;
@@ -222,8 +223,8 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private StatusInfo fValidationStatus;
private boolean fSuppressError= true; // #4354
- private Map fGlobalActions= new HashMap(10);
- private List fSelectionActions = new ArrayList(3);
+ private Map<String, TextViewerAction> fGlobalActions= new HashMap<>(10);
+ private List<String> fSelectionActions = new ArrayList<>(3);
private String[][] fContextTypes;
private ContextTypeRegistry fContextTypeRegistry;
@@ -253,19 +254,19 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
fOriginalTemplate= template;
fIsNameModifiable= isNameModifiable;
- List contexts= new ArrayList();
- for (Iterator it= registry.contextTypes(); it.hasNext();) {
- TemplateContextType type= (TemplateContextType) it.next();
+ List<String[]> contexts= new ArrayList<>();
+ for (Iterator<TemplateContextType> it= registry.contextTypes(); it.hasNext();) {
+ TemplateContextType type= it.next();
contexts.add(new String[] { type.getId(), type.getName() });
}
- Collections.sort(contexts, new Comparator() {
+ Collections.sort(contexts, new Comparator<String[]>() {
Collator fCollator= Collator.getInstance();
@Override
- public int compare(Object o1, Object o2) {
- return fCollator.compare(((String[])o1)[1], ((String[])o2)[1]);
+ public int compare(String[] o1, String[] o2) {
+ return fCollator.compare(o1[1], o2[1]);
}
});
- fContextTypes= (String[][]) contexts.toArray(new String[contexts.size()][]);
+ fContextTypes= contexts.toArray(new String[contexts.size()][]);
fValidationStatus= new StatusInfo();
@@ -550,7 +551,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
}
private void initializeActions() {
- final ArrayList handlerActivations= new ArrayList(3);
+ final ArrayList<IHandlerActivation> handlerActivations= new ArrayList<>(3);
final IHandlerService handlerService= PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
final Expression expression= new ActiveShellExpression(fPatternEditor.getControl().getShell());
@@ -570,11 +571,11 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
@Override
public void focusGained(FocusEvent e) {
- IAction action= (IAction)fGlobalActions.get(ITextEditorActionConstants.REDO);
+ IAction action= fGlobalActions.get(ITextEditorActionConstants.REDO);
handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_REDO, new ActionHandler(action), expression));
- action= (IAction)fGlobalActions.get(ITextEditorActionConstants.UNDO);
+ action= fGlobalActions.get(ITextEditorActionConstants.UNDO);
handlerActivations.add(handlerService.activateHandler(IWorkbenchCommandConstants.EDIT_UNDO, new ActionHandler(action), expression));
- action= (IAction)fGlobalActions.get(ITextEditorActionConstants.CONTENT_ASSIST);
+ action= fGlobalActions.get(ITextEditorActionConstants.CONTENT_ASSIST);
handlerActivations.add(handlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, new ActionHandler(action), expression));
}
});
@@ -628,27 +629,27 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private void fillContextMenu(IMenuManager menu) {
menu.add(new GroupMarker(ITextEditorActionConstants.GROUP_UNDO));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, (IAction) fGlobalActions.get(ITextEditorActionConstants.UNDO));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, (IAction)fGlobalActions.get(ITextEditorActionConstants.REDO));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.UNDO));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_UNDO, fGlobalActions.get(ITextEditorActionConstants.REDO));
menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.CUT));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.COPY));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.PASTE));
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, (IAction) fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.CUT));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.COPY));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.PASTE));
+ menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, fGlobalActions.get(ITextEditorActionConstants.SELECT_ALL));
menu.add(new Separator("templates")); //$NON-NLS-1$
- menu.appendToGroup("templates", (IAction) fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$ //$NON-NLS-2$
+ menu.appendToGroup("templates", fGlobalActions.get("ContentAssistProposal")); //$NON-NLS-1$ //$NON-NLS-2$
}
private void updateSelectionDependentActions() {
- Iterator iterator= fSelectionActions.iterator();
+ Iterator<String> iterator= fSelectionActions.iterator();
while (iterator.hasNext())
- updateAction((String)iterator.next());
+ updateAction(iterator.next());
}
private void updateAction(String actionId) {
- IAction action= (IAction) fGlobalActions.get(actionId);
+ IAction action= fGlobalActions.get(actionId);
if (action instanceof IUpdate)
((IUpdate) action).update();
}
@@ -1069,9 +1070,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
*/
private int computeMinimumContextColumnWidth(GC gc) {
int width= gc.stringExtent(TemplatesMessages.TemplatePreferencePage_column_context).x;
- Iterator iter= getContextTypeRegistry().contextTypes();
+ Iterator<TemplateContextType> iter= getContextTypeRegistry().contextTypes();
while (iter.hasNext()) {
- TemplateContextType contextType= (TemplateContextType)iter.next();
+ TemplateContextType contextType= iter.next();
width= Math.max(width, gc.stringExtent(contextType.getName()).x);
}
return width;
@@ -1106,13 +1107,13 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
}
private TemplatePersistenceData[] getEnabledTemplates() {
- List enabled= new ArrayList();
+ List<TemplatePersistenceData> enabled= new ArrayList<>();
TemplatePersistenceData[] datas= fTemplateStore.getTemplateData(false);
for (int i= 0; i < datas.length; i++) {
if (datas[i].isEnabled())
enabled.add(datas[i]);
}
- return (TemplatePersistenceData[]) enabled.toArray(new TemplatePersistenceData[enabled.size()]);
+ return enabled.toArray(new TemplatePersistenceData[enabled.size()]);
}
private SourceViewer doCreateViewer(Composite parent) {
@@ -1201,7 +1202,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
int itemCount= fTableViewer.getTable().getItemCount();
boolean canRestore= fTemplateStore.getTemplateData(true).length != fTemplateStore.getTemplateData(false).length;
boolean canRevert= false;
- for (Iterator it= selection.iterator(); it.hasNext();) {
+ for (Iterator<?> it= selection.iterator(); it.hasNext();) {
TemplatePersistenceData data= (TemplatePersistenceData) it.next();
if (data.isModified()) {
canRevert= true;
@@ -1218,9 +1219,9 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private void add() {
- Iterator it= fContextTypeRegistry.contextTypes();
+ Iterator<TemplateContextType> it= fContextTypeRegistry.contextTypes();
if (it.hasNext()) {
- Template template= new Template("", "", ((TemplateContextType) it.next()).getId(), "", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Template template= new Template("", "", it.next().getId(), "", true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Template newTemplate= editTemplate(template, false, true);
if (newTemplate != null) {
@@ -1310,7 +1311,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
return;
try {
- ArrayList selection= new ArrayList();
+ ArrayList<TemplatePersistenceData> selection= new ArrayList<>();
TemplateReaderWriter reader= new TemplateReaderWriter();
File file= new File(path);
if (file.exists()) {
@@ -1418,7 +1419,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private void remove() {
IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
- Iterator elements= selection.iterator();
+ Iterator<?> elements= selection.iterator();
while (elements.hasNext()) {
TemplatePersistenceData data= (TemplatePersistenceData) elements.next();
fTemplateStore.delete(data);
@@ -1433,7 +1434,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
TemplatePersistenceData[] newTemplates= fTemplateStore.getTemplateData(false);
fTableViewer.refresh();
fTableViewer.setCheckedElements(getEnabledTemplates());
- ArrayList selection= new ArrayList();
+ ArrayList<TemplatePersistenceData> selection= new ArrayList<>();
selection.addAll(Arrays.asList(newTemplates));
selection.removeAll(Arrays.asList(oldTemplates));
fTableViewer.setSelection(new StructuredSelection(selection), true);
@@ -1443,7 +1444,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private void revert() {
IStructuredSelection selection= (IStructuredSelection) fTableViewer.getSelection();
- Iterator elements= selection.iterator();
+ Iterator<?> elements= selection.iterator();
while (elements.hasNext()) {
TemplatePersistenceData data= (TemplatePersistenceData) elements.next();
data.revert();
@@ -1585,6 +1586,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
String left= ((TemplateLabelProvider)baseLabel).getColumnText(e1, fSortColumn);
String right= ((TemplateLabelProvider)baseLabel).getColumnText(e2, fSortColumn);
+ @SuppressWarnings("unchecked")
int sortResult= getComparator().compare(left, right);
return sortResult * fSortOrder;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java
index 45a35d38228..2a4f66cfd64 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 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
@@ -37,12 +37,9 @@ import org.eclipse.jface.text.templates.TemplateVariableResolver;
*/
final class TemplateVariableProcessor implements IContentAssistProcessor {
- private static Comparator fgTemplateVariableProposalComparator= new Comparator() {
+ private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator= new Comparator<TemplateVariableProposal>() {
@Override
- public int compare(Object arg0, Object arg1) {
- TemplateVariableProposal proposal0= (TemplateVariableProposal) arg0;
- TemplateVariableProposal proposal1= (TemplateVariableProposal) arg1;
-
+ public int compare(TemplateVariableProposal proposal0, TemplateVariableProposal proposal1) {
return proposal0.getDisplayString().compareTo(proposal1.getDisplayString());
}
@@ -89,7 +86,7 @@ final class TemplateVariableProcessor implements IContentAssistProcessor {
if (fContextType == null)
return null;
- List proposals= new ArrayList();
+ List<TemplateVariableProposal> proposals= new ArrayList<>();
String text= viewer.getDocument().get();
int start= getStart(text, documentOffset);
@@ -103,15 +100,15 @@ final class TemplateVariableProcessor implements IContentAssistProcessor {
int offset= start;
int length= end - start;
- for (Iterator iterator= fContextType.resolvers(); iterator.hasNext(); ) {
- TemplateVariableResolver variable= (TemplateVariableResolver) iterator.next();
+ for (Iterator<TemplateVariableResolver> iterator= fContextType.resolvers(); iterator.hasNext(); ) {
+ TemplateVariableResolver variable= iterator.next();
if (prefix == null || variable.getType().startsWith(prefix))
proposals.add(new TemplateVariableProposal(variable, offset, length, viewer));
}
Collections.sort(proposals, fgTemplateVariableProposalComparator);
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+ return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
/* Guesses the start position of the completion */

Back to the top