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.jface.text/src/org
parent0bbe21e0e553957dd09eda0b29e8c77a98f38048 (diff)
downloadeclipse.platform.text-I20151201-0800.tar.gz
eclipse.platform.text-I20151201-0800.tar.xz
eclipse.platform.text-I20151201-0800.zip
Diffstat (limited to 'org.eclipse.jface.text/src/org')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java84
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java12
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java36
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java143
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java25
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java30
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java14
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java5
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java18
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java40
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java20
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java29
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java39
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java98
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java34
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java64
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java45
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java60
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java10
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java46
60 files changed, 622 insertions, 645 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
index 57b16ebe092..221d971e24a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/AbstractControlContentAssistSubjectAdapter.java
@@ -58,11 +58,11 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
/**
* VerifyKeyListeners for the control.
*/
- private List fVerifyKeyListeners;
+ private List<VerifyKeyListener> fVerifyKeyListeners;
/**
* KeyListeners for the control.
*/
- private Set fKeyListeners;
+ private Set<KeyListener> fKeyListeners;
/**
* The Listener installed on the control which passes events to
* {@link #fVerifyKeyListeners fVerifyKeyListeners} and {@link #fKeyListeners}.
@@ -88,8 +88,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
* Creates a new {@link AbstractControlContentAssistSubjectAdapter}.
*/
public AbstractControlContentAssistSubjectAdapter() {
- fVerifyKeyListeners= new ArrayList(1);
- fKeyListeners= new HashSet(1);
+ fVerifyKeyListeners= new ArrayList<>(1);
+ fKeyListeners= new HashSet<>(1);
}
@Override
@@ -192,8 +192,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
dump("before traverse", e, verifyEvent); //$NON-NLS-1$
verifyEvent.doit= true;
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
+ for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
+ iter.next().verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.detail= SWT.TRAVERSE_NONE;
e.doit= true;
@@ -208,8 +208,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
break;
case SWT.KeyDown:
- for (Iterator iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
- ((VerifyKeyListener) iter.next()).verifyKey(verifyEvent);
+ for (Iterator<VerifyKeyListener> iter= fVerifyKeyListeners.iterator(); iter.hasNext(); ) {
+ iter.next().verifyKey(verifyEvent);
if (! verifyEvent.doit) {
e.doit= verifyEvent.doit;
if (DEBUG)
@@ -221,8 +221,8 @@ public abstract class AbstractControlContentAssistSubjectAdapter implements ICon
if (DEBUG)
dump("keyDown OK", e, verifyEvent); //$NON-NLS-1$
- for (Iterator iter= fKeyListeners.iterator(); iter.hasNext();) {
- ((KeyListener) iter.next()).keyPressed(keyEvent);
+ for (Iterator<KeyListener> iter= fKeyListeners.iterator(); iter.hasNext();) {
+ iter.next().keyPressed(keyEvent);
}
break;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
index c4b719507cd..93d98c27c00 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/ComboContentAssistSubjectAdapter.java
@@ -85,7 +85,7 @@ public class ComboContentAssistSubjectAdapter extends AbstractControlContentAssi
* The combo widget.
*/
private Combo fCombo;
- private HashMap fModifyListeners;
+ private HashMap<SelectionListener, Listener> fModifyListeners;
/**
* Creates a content assist subject control adapter for the given combo.
@@ -95,7 +95,7 @@ public class ComboContentAssistSubjectAdapter extends AbstractControlContentAssi
public ComboContentAssistSubjectAdapter(Combo combo) {
Assert.isNotNull(combo);
fCombo= combo;
- fModifyListeners= new HashMap();
+ fModifyListeners= new HashMap<>();
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
index 8dd2244aaee..b47cccde215 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/contentassist/TextContentAssistSubjectAdapter.java
@@ -74,7 +74,7 @@ public class TextContentAssistSubjectAdapter extends AbstractControlContentAssis
/** The text. */
private Text fText;
/** The modify listeners. */
- private HashMap fModifyListeners= new HashMap();
+ private HashMap<SelectionListener, Listener> fModifyListeners= new HashMap<>();
/**
* Creates a content assist subject control adapter for the given text widget.
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
index 67f9b3d74cb..bfc04873562 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.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
@@ -437,9 +437,9 @@ public class BrowserInformationControl extends AbstractInformationControl implem
fTextLayout.setText(text);
fTextLayout.setWidth(sizeConstraints == null ? SWT.DEFAULT : sizeConstraints.x - trim.width);
- Iterator iter= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> iter= presentation.getAllStyleRangeIterator();
while (iter.hasNext()) {
- StyleRange sr= (StyleRange)iter.next();
+ StyleRange sr= iter.next();
if (sr.fontStyle == SWT.BOLD)
fTextLayout.setStyle(fBoldStyle, sr.start, sr.start + sr.length - 1);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
index 290a684de35..9aef7af8999 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
@@ -33,12 +33,12 @@ import org.eclipse.jface.text.TextPresentation;
public class HTML2TextReader extends SubstitutionTextReader {
private static final String EMPTY_STRING= ""; //$NON-NLS-1$
- private static final Map fgEntityLookup;
- private static final Set fgTags;
+ private static final Map<String, String> fgEntityLookup;
+ private static final Set<String> fgTags;
static {
- fgTags= new HashSet();
+ fgTags= new HashSet<>();
fgTags.add("b"); //$NON-NLS-1$
fgTags.add("br"); //$NON-NLS-1$
fgTags.add("br/"); //$NON-NLS-1$
@@ -58,7 +58,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
fgTags.add("pre"); //$NON-NLS-1$
fgTags.add("head"); //$NON-NLS-1$
- fgEntityLookup= new HashMap(7);
+ fgEntityLookup= new HashMap<>(7);
fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -351,7 +351,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
} catch (NumberFormatException e) {
}
} else {
- String str= (String) fgEntityLookup.get(symbol);
+ String str= fgEntityLookup.get(symbol);
if (str != null) {
return str;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java
index 341452782dd..b88aa2762ab 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTMLTextPresenter.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
@@ -57,10 +57,10 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation
int yoursEnd= offset + insertLength -1;
yoursEnd= Math.max(yoursStart, yoursEnd);
- Iterator e= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
+ StyleRange range= e.next();
int myStart= range.start;
int myEnd= range.start + range.length -1;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
index 188df4e69ac..4d6a932b403 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/CompletionProposalPopup2.java
@@ -85,7 +85,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
/** The key listener to control navigation */
private KeyListener fKeyListener;
/** List of document events used for filtering proposals */
- private List fDocumentEvents= new ArrayList();
+ private List<DocumentEvent> fDocumentEvents= new ArrayList<>();
/** Listener filling the document event queue */
private IDocumentListener fDocumentListener;
/** Reentrance count for <code>filterProposals</code> */
@@ -936,7 +936,7 @@ class CompletionProposalPopup2 implements IContentAssistListener2 {
IDocument document= fViewer.getDocument();
int length= proposals.length;
- List filtered= new ArrayList(length);
+ List<Object> filtered= new ArrayList<>(length);
for (int i= 0; i < length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension2) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
index f8993b471ea..26ea2ecc0f3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContentAssistant2.java
@@ -667,7 +667,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private boolean fIsAutoInserting= false;
private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
+ private Map<String, IContentAssistProcessor> fProcessors;
private String fPartitioning;
private Color fContextInfoPopupBackground;
@@ -690,7 +690,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
private int fCompletionPosition;
private String[] fProposalStrings;
private ICompletionProposal[] fProposals;
- private final List fProposalListeners= new ArrayList();
+ private final List<IProposalListener> fProposalListeners= new ArrayList<>();
/**
* Tells whether colored label support is enabled.
@@ -764,7 +764,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
Assert.isNotNull(contentType);
if (fProcessors == null)
- fProcessors= new HashMap();
+ fProcessors= new HashMap<>();
if (processor == null)
fProcessors.remove(contentType);
@@ -780,7 +780,7 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
if (fProcessors == null)
return null;
- return (IContentAssistProcessor) fProcessors.get(contentType);
+ return fProcessors.get(contentType);
}
/**
@@ -1522,9 +1522,9 @@ public class ContentAssistant2 implements IContentAssistant, IContentAssistantEx
* @param proposal the proposal
*/
public void fireProposalChosen(ICompletionProposal proposal) {
- List list= new ArrayList(fProposalListeners);
- for (Iterator it= list.iterator(); it.hasNext();) {
- IProposalListener listener= (IProposalListener) it.next();
+ List<IProposalListener> list= new ArrayList<>(fProposalListeners);
+ for (Iterator<IProposalListener> it= list.iterator(); it.hasNext();) {
+ IProposalListener listener= it.next();
listener.proposalChosen(proposal);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index 766c134b338..ce022e648c0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.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
@@ -84,7 +84,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
private StyledText fContextInfoText;
private TextPresentation fTextPresentation;
- private Stack fContextFrameStack= new Stack();
+ private Stack<ContextFrame> fContextFrameStack= new Stack<>();
/**
@@ -291,7 +291,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
}
if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame current= fContextFrameStack.peek();
internalShowContextFrame(current, false);
} else {
@@ -619,7 +619,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
*/
fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
+ private ContextFrame fFrame= fContextFrameStack.peek();
@Override
public void run() {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
index ac3aeef7648..84f4a8d6dd5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/ChangeRegion.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
@@ -30,7 +30,7 @@ import org.eclipse.jface.text.source.LineRange;
public final class ChangeRegion {
private final Revision fRevision;
private final ILineRange fLines;
- private final List fAdjusted= new LinkedList();
+ private final List<Range> fAdjusted= new LinkedList<>();
/**
* Creates a new change region for the given revision and line range.
@@ -66,12 +66,12 @@ public final class ChangeRegion {
}
/**
- * Returns the list of {@link ILineRange}s of this change region for which the revision
+ * Returns the list of {@link Range}s of this change region for which the revision
* information is still valid.
*
* @return the list of adjusted line ranges
*/
- public List getAdjustedRanges() {
+ public List<Range> getAdjustedRanges() {
return fAdjusted;
}
@@ -84,8 +84,8 @@ public final class ChangeRegion {
if (fAdjusted.isEmpty())
return new LineRange(fLines.getStartLine(), 0);
- Range first= (Range) fAdjusted.get(0);
- Range last= (Range) fAdjusted.get(fAdjusted.size() - 1);
+ Range first= fAdjusted.get(0);
+ Range last= fAdjusted.get(fAdjusted.size() - 1);
return Range.createAbsolute(first.start(), last.end());
}
@@ -104,8 +104,8 @@ public final class ChangeRegion {
* @param hunk the diff hunk to adjust to
*/
public void adjustTo(Hunk hunk) {
- for (ListIterator it= fAdjusted.listIterator(); it.hasNext();) {
- Range range= (Range) it.next();
+ for (ListIterator<Range> it= fAdjusted.listIterator(); it.hasNext();) {
+ Range range= it.next();
// do we need a split?
int unchanged= getUnchanged(hunk, range.start());
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
index 3e527e5790d..2e2d49026c4 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/HunkComputer.java
@@ -32,7 +32,7 @@ public final class HunkComputer {
* @return the corresponding {@link Hunk} information
*/
public static Hunk[] computeHunks(ILineDiffer differ, int lines) {
- List hunks= new ArrayList(lines);
+ List<Hunk> hunks= new ArrayList<>(lines);
int added= 0;
int changed= 0;
@@ -70,7 +70,7 @@ public final class HunkComputer {
}
}
- return (Hunk[]) hunks.toArray(new Hunk[hunks.size()]);
+ return hunks.toArray(new Hunk[hunks.size()]);
}
private HunkComputer() {
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
index 2fbbb36dea9..91d5e026d2c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/revisions/RevisionPainter.java
@@ -138,15 +138,15 @@ public final class RevisionPainter {
/**
* A list of {@link Long}, storing the age of each revision in a sorted list.
*/
- private List fRevisions;
+ private List<Long> fRevisions;
/**
* The stored shaded colors.
*/
- private final Map fColors= new HashMap();
+ private final Map<Revision, RGB> fColors= new HashMap<>();
/**
* The stored focus colors.
*/
- private final Map fFocusColors= new HashMap();
+ private final Map<Revision, RGB> fFocusColors= new HashMap<>();
/**
* Sets the revision information, which is needed to compute the relative age of a revision.
@@ -160,9 +160,9 @@ public final class RevisionPainter {
if (info == null)
return;
- List revisions= new ArrayList();
- for (Iterator it= info.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ List<Long> revisions= new ArrayList<>();
+ for (Iterator<Revision> it= info.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
revisions.add(new Long(computeAge(revision)));
}
Collections.sort(revisions);
@@ -248,8 +248,8 @@ public final class RevisionPainter {
* @return the color for a revision
*/
public RGB getColor(Revision revision, boolean focus) {
- Map map= focus ? fFocusColors : fColors;
- RGB color= (RGB) map.get(revision);
+ Map<Revision, RGB> map= focus ? fFocusColors : fColors;
+ RGB color= map.get(revision);
if (color != null)
return color;
@@ -533,9 +533,9 @@ public final class RevisionPainter {
/* Cache. */
/** The cached list of ranges adapted to quick diff. */
- private List fRevisionRanges= null;
+ private List<RevisionRange> fRevisionRanges= null;
/** The annotations created for the overview ruler temporary display. */
- private List fAnnotations= new ArrayList();
+ private List<Annotation> fAnnotations= new ArrayList<>();
/* State */
@@ -693,9 +693,9 @@ public final class RevisionPainter {
}
// draw change regions
- List/* <RevisionRange> */ranges= getRanges(visibleLines);
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange region= (RevisionRange) it.next();
+ List<RevisionRange> ranges= getRanges(visibleLines);
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange region= it.next();
paintRange(region, gc);
}
}
@@ -902,19 +902,19 @@ public final class RevisionPainter {
* @return the corresponding <code>RevisionRange</code> or <code>null</code>
*/
private RevisionRange getRange(int line) {
- List ranges= getRangeCache();
+ List<RevisionRange> ranges= getRangeCache();
if (ranges.isEmpty() || line == -1)
return null;
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
if (contains(range, line))
return range;
}
// line may be right after the last region
- RevisionRange lastRegion= (RevisionRange) ranges.get(ranges.size() - 1);
+ RevisionRange lastRegion= ranges.get(ranges.size() - 1);
if (line == end(lastRegion))
return lastRegion;
return null;
@@ -926,14 +926,14 @@ public final class RevisionPainter {
* @param lines the model based lines of interest
* @return elementType: RevisionRange
*/
- private List getRanges(ILineRange lines) {
- List ranges= getRangeCache();
+ private List<RevisionRange> getRanges(ILineRange lines) {
+ List<RevisionRange> ranges= getRangeCache();
// return the interesting subset
int end= end(lines);
int first= -1, last= -1;
for (int i= 0; i < ranges.size(); i++) {
- RevisionRange range= (RevisionRange) ranges.get(i);
+ RevisionRange range= ranges.get(i);
int rangeEnd= end(range);
if (first == -1 && rangeEnd > lines.getStartLine())
first= i;
@@ -943,7 +943,7 @@ public final class RevisionPainter {
}
}
if (first == -1)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
if (last == -1)
last= ranges.size() - 1; // bottom index may be one too much
@@ -956,10 +956,10 @@ public final class RevisionPainter {
*
* @return the list of all change regions, with diff information applied
*/
- private synchronized List getRangeCache() {
+ private synchronized List<RevisionRange> getRangeCache() {
if (fRevisionRanges == null) {
if (fRevisionInfo == null) {
- fRevisionRanges= Collections.EMPTY_LIST;
+ fRevisionRanges= Collections.emptyList();
} else {
Hunk[] hunks= HunkComputer.computeHunks(fLineDiffer, fViewer.getDocument().getNumberOfLines());
fRevisionInfo.applyDiff(hunks);
@@ -1075,11 +1075,11 @@ public final class RevisionPainter {
Revision revision= fFocusRevision != null ? fFocusRevision : fSelectedRevision;
- Map added= null;
+ Map<Annotation, Position> added= null;
if (revision != null) {
- added= new HashMap();
- for (Iterator it= revision.getRegions().iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ added= new HashMap<>();
+ for (Iterator<RevisionRange> it= revision.getRegions().iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
try {
IRegion charRegion= toCharRegion(range);
Position position= new Position(charRegion.getOffset(), charRegion.getLength());
@@ -1093,16 +1093,16 @@ public final class RevisionPainter {
if (fAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext= (IAnnotationModelExtension) fAnnotationModel;
- ext.replaceAnnotations((Annotation[]) fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
+ ext.replaceAnnotations(fAnnotations.toArray(new Annotation[fAnnotations.size()]), added);
} else {
- for (Iterator it= fAnnotations.iterator(); it.hasNext();) {
- Annotation annotation= (Annotation) it.next();
+ for (Iterator<Annotation> it= fAnnotations.iterator(); it.hasNext();) {
+ Annotation annotation= it.next();
fAnnotationModel.removeAnnotation(annotation);
}
if (added != null) {
- for (Iterator it= added.entrySet().iterator(); it.hasNext();) {
- Entry entry= (Entry) it.next();
- fAnnotationModel.addAnnotation((Annotation) entry.getKey(), (Position) entry.getValue());
+ for (Iterator<Entry<Annotation, Position>> it= added.entrySet().iterator(); it.hasNext();) {
+ Entry<Annotation, Position> entry= it.next();
+ fAnnotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
}
@@ -1156,8 +1156,8 @@ public final class RevisionPainter {
if (fRevisionInfo == null)
return;
- for (Iterator it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
if (id.equals(revision.getId())) {
handleRevisionSelected(revision);
return;
@@ -1287,10 +1287,10 @@ public final class RevisionPainter {
ILineRange nextWidgetRange= null;
ILineRange last= null;
- List ranges= fFocusRevision.getRegions();
+ List<RevisionRange> ranges= fFocusRevision.getRegions();
if (up) {
- for (Iterator it= ranges.iterator(); it.hasNext();) {
- RevisionRange range= (RevisionRange) it.next();
+ for (Iterator<RevisionRange> it= ranges.iterator(); it.hasNext();) {
+ RevisionRange range= it.next();
ILineRange widgetRange= modelLinesToWidgetLines(range);
if (contains(range, documentHoverLine)) {
nextWidgetRange= last;
@@ -1300,8 +1300,8 @@ public final class RevisionPainter {
last= widgetRange;
}
} else {
- for (ListIterator it= ranges.listIterator(ranges.size()); it.hasPrevious();) {
- RevisionRange range= (RevisionRange) it.previous();
+ for (ListIterator<RevisionRange> it= ranges.listIterator(ranges.size()); it.hasPrevious();) {
+ RevisionRange range= it.previous();
ILineRange widgetRange= modelLinesToWidgetLines(range);
if (contains(range, documentHoverLine)) {
nextWidgetRange= last;
@@ -1459,8 +1459,8 @@ public final class RevisionPainter {
if (hasInformation() && (fShowRevision || fShowAuthor)) {
int revisionWidth= 0;
int authorWidth= 0;
- for (Iterator it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ for (Iterator<Revision> it= fRevisionInfo.getRevisions().iterator(); it.hasNext();) {
+ Revision revision= it.next();
revisionWidth= Math.max(revisionWidth, revision.getId().length());
authorWidth= Math.max(authorWidth, revision.getAuthor().length());
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
index 94fc583607b..a28f14bfe59 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractReusableInformationControlCreator.java
@@ -26,7 +26,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public abstract class AbstractReusableInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension, DisposeListener {
- private Map fInformationControls= new HashMap();
+ private Map<Shell, IInformationControl> fInformationControls= new HashMap<>();
/**
* Creates the control.
@@ -38,7 +38,7 @@ public abstract class AbstractReusableInformationControlCreator implements IInfo
@Override
public IInformationControl createInformationControl(Shell parent) {
- IInformationControl control= (IInformationControl)fInformationControls.get(parent);
+ IInformationControl control= fInformationControls.get(parent);
if (control == null) {
control= doCreateInformationControl(parent);
control.addDisposeListener(this);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
index 9c4704e7517..28cb78a473f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
@@ -40,7 +40,7 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
/** The original line delimiters */
private String[] fOriginalLineDelimiters;
/** The registered text change listeners */
- private List fTextChangeListeners= new ArrayList(1);
+ private List<TextChangeListener> fTextChangeListeners= new ArrayList<>(1);
/**
* The remembered document event
* @since 2.0
@@ -317,9 +317,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event= new TextChangedEvent(this);
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textChanged(event);
+ e.next().textChanged(event);
}
}
@@ -334,9 +334,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event = new TextChangedEvent(this);
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textSet(event);
+ e.next().textSet(event);
}
}
@@ -362,9 +362,9 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
event.newLineCount= (fEvent.fText == null ? 0 : document.computeNumberOfLines(fEvent.fText));
if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
- Iterator e= new ArrayList(fTextChangeListeners).iterator();
+ Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
- ((TextChangeListener) e.next()).textChanging(event);
+ e.next().textChanging(event);
}
} catch (BadLocationException e) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
index d7551522243..ab30e23d784 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.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
@@ -51,9 +51,9 @@ public class DefaultTextHover implements ITextHover {
if (model == null)
return null;
- Iterator e= model.getAnnotationIterator();
+ Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (isIncluded(a)) {
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
index ae95f9bb426..fb9b366a6f8 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.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
@@ -424,7 +424,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
class CompoundTextCommand extends TextCommand {
/** The list of individual commands */
- private List fCommands= new ArrayList();
+ private List<TextCommand> fCommands= new ArrayList<>();
/**
* Creates a new compound text command.
@@ -455,11 +455,11 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
TextCommand c;
for (int i= size -1; i > 0; --i) {
- c= (TextCommand) fCommands.get(i);
+ c= fCommands.get(i);
c.undoTextChange();
}
- c= (TextCommand) fCommands.get(0);
+ c= fCommands.get(0);
c.undo(monitor, uiInfo);
}
@@ -476,11 +476,11 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
TextCommand c;
for (int i= 0; i < size -1; ++i) {
- c= (TextCommand) fCommands.get(i);
+ c= fCommands.get(i);
c.redoTextChange();
}
- c= (TextCommand) fCommands.get(size -1);
+ c= fCommands.get(size -1);
c.redo(monitor, uiInfo);
}
return Status.OK_STATUS;
@@ -556,7 +556,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
if (fStart > -1)
return super.getUndoModificationStamp();
else if (fCommands.size() > 0)
- return ((TextCommand)fCommands.get(0)).getUndoModificationStamp();
+ return fCommands.get(0).getUndoModificationStamp();
return fUndoModificationStamp;
}
@@ -572,7 +572,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
if (fStart > -1)
return super.getRedoModificationStamp();
else if (fCommands.size() > 0)
- return ((TextCommand)fCommands.get(fCommands.size()-1)).getRedoModificationStamp();
+ return fCommands.get(fCommands.size()-1).getRedoModificationStamp();
return fRedoModificationStamp;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
index 554032cfefe..cc3731f6051 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DocumentCommand.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
@@ -37,7 +37,7 @@ public class DocumentCommand {
* A command which is added to document commands.
* @since 2.1
*/
- private static class Command implements Comparable {
+ private static class Command implements Comparable<Command> {
/** The offset of the range to be replaced */
private final int fOffset;
/** The length of the range to be replaced. */
@@ -85,15 +85,12 @@ public class DocumentCommand {
document.addDocumentListener(fOwner);
}
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
@Override
- public int compareTo(final Object object) {
+ public int compareTo(Command object) {
if (isEqual(object))
return 0;
- final Command command= (Command) object;
+ Command command= object;
// diff middle points if not intersecting
if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) {
@@ -117,17 +114,19 @@ public class DocumentCommand {
/**
* An iterator, which iterates in reverse over a list.
+ *
+ * @param <E> the type of elements returned by this iterator
*/
- private static class ReverseListIterator implements Iterator {
+ private static class ReverseListIterator<E> implements Iterator<E> {
/** The list iterator. */
- private final ListIterator fListIterator;
+ private final ListIterator<E> fListIterator;
/**
* Creates a reverse list iterator.
* @param listIterator the iterator that this reverse iterator is based upon
*/
- public ReverseListIterator(ListIterator listIterator) {
+ public ReverseListIterator(ListIterator<E> listIterator) {
if (listIterator == null)
throw new IllegalArgumentException();
fListIterator= listIterator;
@@ -139,7 +138,7 @@ public class DocumentCommand {
}
@Override
- public Object next() {
+ public E next() {
return fListIterator.previous();
}
@@ -152,10 +151,10 @@ public class DocumentCommand {
/**
* A command iterator.
*/
- private static class CommandIterator implements Iterator {
+ private static class CommandIterator implements Iterator<Command> {
/** The command iterator. */
- private final Iterator fIterator;
+ private final Iterator<Command> fIterator;
/** The original command. */
private Command fCommand;
@@ -170,10 +169,10 @@ public class DocumentCommand {
* @param command the original command
* @param forward the direction
*/
- public CommandIterator(final List commands, final Command command, final boolean forward) {
+ public CommandIterator(final List<Command> commands, final Command command, final boolean forward) {
if (commands == null || command == null)
throw new IllegalArgumentException();
- fIterator= forward ? commands.iterator() : new ReverseListIterator(commands.listIterator(commands.size()));
+ fIterator= forward ? commands.iterator() : new ReverseListIterator<>(commands.listIterator(commands.size()));
fCommand= command;
fForward= forward;
}
@@ -184,7 +183,7 @@ public class DocumentCommand {
}
@Override
- public Object next() {
+ public Command next() {
if (!hasNext())
throw new NoSuchElementException();
@@ -198,7 +197,7 @@ public class DocumentCommand {
return tempCommand;
}
- final Command command= (Command) fIterator.next();
+ final Command command= fIterator.next();
final int compareValue= command.compareTo(fCommand);
if ((compareValue < 0) ^ !fForward) {
@@ -242,7 +241,7 @@ public class DocumentCommand {
* Additional document commands.
* @since 2.1
*/
- private final List fCommands= new ArrayList();
+ private final List<Command> fCommands= new ArrayList<>();
/**
* Indicates whether the caret should be shifted by this command.
* @since 3.0
@@ -319,11 +318,11 @@ public class DocumentCommand {
final int insertionIndex= -(index + 1);
// overlaps to the right?
- if (insertionIndex != fCommands.size() && intersects((Command) fCommands.get(insertionIndex), command))
+ if (insertionIndex != fCommands.size() && intersects(fCommands.get(insertionIndex), command))
throw new BadLocationException();
// overlaps to the left?
- if (insertionIndex != 0 && intersects((Command) fCommands.get(insertionIndex - 1), command))
+ if (insertionIndex != 0 && intersects(fCommands.get(insertionIndex - 1), command))
throw new BadLocationException();
fCommands.add(insertionIndex, command);
@@ -336,7 +335,7 @@ public class DocumentCommand {
*
* @return returns the command iterator
*/
- public Iterator getCommandIterator() {
+ public Iterator<Command> getCommandIterator() {
Command command= new Command(offset, length, text, owner);
return new CommandIterator(fCommands, command, true);
}
@@ -403,8 +402,8 @@ public class DocumentCommand {
}
final Command originalCommand= new Command(offset, length, text, owner);
- for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
- ((Command) iterator.next()).execute(document);
+ for (final Iterator<Command> iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
+ iterator.next().execute(document);
} catch (BadLocationException e) {
// ignore
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
index 37089e74f54..4d9a270f3d0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapterContentProposalProvider.java
@@ -51,11 +51,11 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
/**
* The high-priority proposals.
*/
- private final ArrayList fPriorityProposals;
+ private final ArrayList<ContentProposal> fPriorityProposals;
/**
* The low-priority proposals.
*/
- private final ArrayList fProposals;
+ private final ArrayList<ContentProposal> fProposals;
/**
* <code>true</code> iff <code>fExpression</code> ends with an open escape.
*/
@@ -69,8 +69,8 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
public ProposalComputer(String contents, int position) {
fExpression= contents;
fDocumentOffset= position;
- fPriorityProposals= new ArrayList();
- fProposals= new ArrayList();
+ fPriorityProposals= new ArrayList<>();
+ fProposals= new ArrayList<>();
boolean isEscape= false;
esc: for (int i= position - 1; i >= 0; i--) {
@@ -196,7 +196,7 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
}
fPriorityProposals.addAll(fProposals);
- return (IContentProposal[]) fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
+ return fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
}
/**
@@ -224,7 +224,7 @@ public class FindReplaceDocumentAdapterContentProposalProvider implements IConte
addBsProposal("\\C", RegExMessages.getString("displayString_replace_bs_C"), RegExMessages.getString("additionalInfo_replace_bs_C")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
fPriorityProposals.addAll(fProposals);
- return (IContentProposal[]) fPriorityProposals.toArray(new IContentProposal[fPriorityProposals.size()]);
+ return fPriorityProposals.toArray(new IContentProposal[fPriorityProposals.size()]);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
index 0220b5f2984..551bc5b845f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/PaintManager.java
@@ -172,7 +172,7 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
/** The painters managed by this paint manager. */
- private List fPainters= new ArrayList(2);
+ private List<IPainter> fPainters= new ArrayList<>(2);
/** The position manager used by this paint manager */
private PositionManager fManager;
/** The associated text viewer */
@@ -264,8 +264,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
fManager= null;
}
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).dispose();
+ for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
+ e.next().dispose();
fPainters.clear();
fTextViewer.removeTextInputListener(this);
@@ -298,8 +298,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
* @see IPainter
*/
private void paint(int reason) {
- for (Iterator e = fPainters.iterator(); e.hasNext();)
- ((IPainter) e.next()).paint(reason);
+ for (Iterator<IPainter> e = fPainters.iterator(); e.hasNext();)
+ e.next().paint(reason);
}
@Override
@@ -350,8 +350,8 @@ public final class PaintManager implements KeyListener, MouseListener, ISelectio
@Override
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
if (oldInput != null) {
- for (Iterator e= fPainters.iterator(); e.hasNext();)
- ((IPainter)e.next()).deactivate(false);
+ for (Iterator<IPainter> e= fPainters.iterator(); e.hasNext();)
+ e.next().deactivate(false);
fManager.uninstall(oldInput);
removeListeners();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
index 6730ae24f52..d38b0790102 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextPresentation.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
@@ -48,9 +48,9 @@ public class TextPresentation {
StyleRange[] ranges= new StyleRange[presentation.getDenumerableRanges()];
int i= 0;
- Iterator e= presentation.getAllStyleRangeIterator();
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext())
- ranges[i++]= (StyleRange) e.next();
+ ranges[i++]= e.next();
text.setStyleRanges(ranges);
}
@@ -61,7 +61,7 @@ public class TextPresentation {
/**
* Enumerates all the <code>StyleRange</code>s included in the presentation.
*/
- class FilterIterator implements Iterator {
+ class FilterIterator implements Iterator<StyleRange> {
/** The index of the next style range to be enumerated */
protected int fIndex;
@@ -91,9 +91,9 @@ public class TextPresentation {
}
@Override
- public Object next() {
+ public StyleRange next() {
try {
- StyleRange r= (StyleRange) fRanges.get(fIndex++);
+ StyleRange r= fRanges.get(fIndex++);
return createWindowRelativeRange(fWindow, r);
} catch (ArrayIndexOutOfBoundsException x) {
throw new NoSuchElementException();
@@ -136,7 +136,7 @@ public class TextPresentation {
/** The style information for the range covered by the whole presentation */
private StyleRange fDefaultRange;
/** The member ranges of the presentation */
- private ArrayList fRanges;
+ private ArrayList<StyleRange> fRanges;
/** A clipping region against which the presentation can be clipped when asked for results */
private IRegion fResultWindow;
/**
@@ -150,7 +150,7 @@ public class TextPresentation {
* Creates a new empty text presentation.
*/
public TextPresentation() {
- fRanges= new ArrayList(50);
+ fRanges= new ArrayList<>(50);
}
/**
@@ -161,7 +161,7 @@ public class TextPresentation {
*/
public TextPresentation(int sizeHint) {
Assert.isTrue(sizeHint > 0);
- fRanges= new ArrayList(sizeHint);
+ fRanges= new ArrayList<>(sizeHint);
}
/**
@@ -294,7 +294,7 @@ public class TextPresentation {
int last= getFirstIndexAfterWindow(rangeRegion);
for (int i= first; i < last && length > 0; i++) {
- StyleRange current= (StyleRange)fRanges.get(i);
+ StyleRange current= fRanges.get(i);
int currentStart= current.start;
int currentEnd= currentStart + current.length;
@@ -405,8 +405,8 @@ public class TextPresentation {
*/
private void applyStyleRanges(StyleRange[] ranges, boolean merge) {
int j= 0;
- ArrayList oldRanges= fRanges;
- ArrayList newRanges= new ArrayList(2*ranges.length + oldRanges.size());
+ ArrayList<StyleRange> oldRanges= fRanges;
+ ArrayList<StyleRange> newRanges= new ArrayList<>(2*ranges.length + oldRanges.size());
for (int i= 0, n= ranges.length; i < n; i++) {
StyleRange range= ranges[i];
fRanges= oldRanges; // for getFirstIndexAfterWindow(...)
@@ -511,7 +511,7 @@ public class TextPresentation {
int i= -1, j= fRanges.size();
while (j - i > 1) {
int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
+ StyleRange r= fRanges.get(k);
if (r.start + r.length > start)
j= k;
else
@@ -535,7 +535,7 @@ public class TextPresentation {
int i= -1, j= fRanges.size();
while (j - i > 1) {
int k= (i + j) >> 1;
- StyleRange r= (StyleRange) fRanges.get(k);
+ StyleRange r= fRanges.get(k);
if (r.start < end)
i= k;
else
@@ -605,7 +605,7 @@ public class TextPresentation {
*
* @return a style range iterator
*/
- public Iterator getNonDefaultStyleRangeIterator() {
+ public Iterator<StyleRange> getNonDefaultStyleRangeIterator() {
return new FilterIterator(fDefaultRange != null);
}
@@ -616,7 +616,7 @@ public class TextPresentation {
*
* @return a style range iterator
*/
- public Iterator getAllStyleRangeIterator() {
+ public Iterator<StyleRange> getAllStyleRangeIterator() {
return new FilterIterator(false);
}
@@ -650,7 +650,7 @@ public class TextPresentation {
public StyleRange getFirstStyleRange() {
try {
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexInWindow(fResultWindow));
+ StyleRange range= fRanges.get(getFirstIndexInWindow(fResultWindow));
return createWindowRelativeRange(fResultWindow, range);
} catch (NoSuchElementException x) {
@@ -668,7 +668,7 @@ public class TextPresentation {
public StyleRange getLastStyleRange() {
try {
- StyleRange range= (StyleRange) fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
+ StyleRange range= fRanges.get(getFirstIndexAfterWindow(fResultWindow) - 1);
return createWindowRelativeRange(fResultWindow, range);
} catch (NoSuchElementException x) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index fe62f16a3f7..adf4e39098f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -466,9 +466,9 @@ public class TextViewer extends Viewer implements
}
/** List of registered verify key listeners. */
- private List fListeners= new ArrayList();
+ private List<VerifyKeyListener> fListeners= new ArrayList<>();
/** List of pending batches. */
- private List fBatched= new ArrayList();
+ private List<Batch> fBatched= new ArrayList<>();
/** The reentrance count. */
private int fReentranceCount= 0;
@@ -479,9 +479,9 @@ public class TextViewer extends Viewer implements
try {
fReentranceCount++;
- Iterator iterator= fListeners.iterator();
+ Iterator<VerifyKeyListener> iterator= fListeners.iterator();
while (iterator.hasNext() && event.doit) {
- VerifyKeyListener listener= (VerifyKeyListener) iterator.next();
+ VerifyKeyListener listener= iterator.next();
listener.verifyKey(event); // we might trigger reentrant calls on GTK
}
} finally {
@@ -496,9 +496,9 @@ public class TextViewer extends Viewer implements
*/
private void processBatchedRequests() {
if (!fBatched.isEmpty()) {
- Iterator e= fBatched.iterator();
+ Iterator<Batch> e= fBatched.iterator();
while (e.hasNext()) {
- Batch batch= (Batch) e.next();
+ Batch batch= e.next();
insertListener(batch.listener, batch.index);
}
fBatched.clear();
@@ -777,7 +777,7 @@ public class TextViewer extends Viewer implements
/** The highlight color of the range of this target. */
private Color fScopeHighlightColor;
/** The document partitioner remembered in case of a "Replace All". */
- private Map fRememberedPartitioners;
+ private Map<String, IDocumentPartitioner> fRememberedPartitioners;
/**
* The active rewrite session.
* @since 3.1
@@ -1522,7 +1522,7 @@ public class TextViewer extends Viewer implements
* The registered post selection changed listeners.
* @since 3.0
*/
- private List fPostSelectionChangedListeners;
+ private List<ISelectionChangedListener> fPostSelectionChangedListeners;
/**
* Queued post selection changed events count.
* @since 3.0
@@ -1537,7 +1537,7 @@ public class TextViewer extends Viewer implements
* The set of registered editor helpers.
* @since 3.1
*/
- private Set fEditorHelpers= new HashSet();
+ private Set<IEditingSupport> fEditorHelpers= new HashSet<>();
/**
* The internal rewrite session listener.
* @since 3.1
@@ -1547,25 +1547,25 @@ public class TextViewer extends Viewer implements
/** Should the auto indent strategies ignore the next edit operation */
protected boolean fIgnoreAutoIndent= false;
/** The strings a line is prefixed with on SHIFT_RIGHT and removed from each line on SHIFT_LEFT */
- protected Map fIndentChars;
+ protected Map<String, String[]> fIndentChars;
/** The string a line is prefixed with on PREFIX and removed from each line on STRIP_PREFIX */
- protected Map fDefaultPrefixChars;
+ protected Map<String, String[]> fDefaultPrefixChars;
/** The text viewer's text double click strategies */
- protected Map fDoubleClickStrategies;
+ protected Map<String, ITextDoubleClickStrategy> fDoubleClickStrategies;
/** The text viewer's undo manager */
protected IUndoManager fUndoManager;
/** The text viewer's auto indent strategies */
- protected Map fAutoIndentStrategies;
+ protected Map<String, List<IAutoEditStrategy>> fAutoIndentStrategies;
/** The text viewer's text hovers */
- protected Map fTextHovers;
+ protected Map<TextHoverKey, ITextHover> fTextHovers;
/** All registered view port listeners> */
- protected List fViewportListeners;
+ protected List<IViewportListener> fViewportListeners;
/** The last visible vertical position of the top line */
protected int fLastTopPixel;
/** All registered text listeners */
- protected List fTextListeners;
+ protected List<ITextListener> fTextListeners;
/** All registered text input listeners */
- protected List fTextInputListeners;
+ protected List<ITextInputListener> fTextInputListeners;
/** The text viewer's event consumer */
protected IEventConsumer fEventConsumer;
/** Indicates whether the viewer's text presentation should be replaced are modified. */
@@ -1594,7 +1594,7 @@ public class TextViewer extends Viewer implements
* All registered text presentation listeners.
* since 3.0
*/
- protected List fTextPresentationListeners;
+ protected List<ITextPresentationListener> fTextPresentationListeners;
/**
* The find/replace document adapter.
* @since 3.0
@@ -1953,9 +1953,9 @@ public class TextViewer extends Viewer implements
*/
protected final void setAutoEditStrategies(IAutoEditStrategy[] strategies, String contentType) {
if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
+ fAutoIndentStrategies= new HashMap<>();
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (strategies == null) {
if (autoEditStrategies == null)
@@ -1965,7 +1965,7 @@ public class TextViewer extends Viewer implements
} else {
if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
+ autoEditStrategies= new ArrayList<>();
fAutoIndentStrategies.put(contentType, autoEditStrategies);
}
@@ -1981,11 +1981,11 @@ public class TextViewer extends Viewer implements
throw new IllegalArgumentException();
if (fAutoIndentStrategies == null)
- fAutoIndentStrategies= new HashMap();
+ fAutoIndentStrategies= new HashMap<>();
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (autoEditStrategies == null) {
- autoEditStrategies= new ArrayList();
+ autoEditStrategies= new ArrayList<>();
fAutoIndentStrategies.put(contentType, autoEditStrategies);
}
@@ -1997,11 +1997,11 @@ public class TextViewer extends Viewer implements
if (fAutoIndentStrategies == null)
return;
- List autoEditStrategies= (List) fAutoIndentStrategies.get(contentType);
+ List<IAutoEditStrategy> autoEditStrategies= fAutoIndentStrategies.get(contentType);
if (autoEditStrategies == null)
return;
- for (final Iterator iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
+ for (final Iterator<IAutoEditStrategy> iterator= autoEditStrategies.iterator(); iterator.hasNext(); ) {
if (iterator.next().equals(strategy)) {
iterator.remove();
break;
@@ -2028,7 +2028,7 @@ public class TextViewer extends Viewer implements
if (ok) {
if (fIndentChars == null)
- fIndentChars= new HashMap();
+ fIndentChars= new HashMap<>();
fIndentChars.put(contentType, indentPrefixes);
@@ -2063,7 +2063,7 @@ public class TextViewer extends Viewer implements
if (defaultPrefixes != null && defaultPrefixes.length > 0) {
if (fDefaultPrefixChars == null)
- fDefaultPrefixChars= new HashMap();
+ fDefaultPrefixChars= new HashMap<>();
fDefaultPrefixChars.put(contentType, defaultPrefixes);
} else if (fDefaultPrefixChars != null)
fDefaultPrefixChars.remove(contentType);
@@ -2089,7 +2089,7 @@ public class TextViewer extends Viewer implements
TextHoverKey key= new TextHoverKey(contentType, stateMask);
if (hover != null) {
if (fTextHovers == null) {
- fTextHovers= new HashMap();
+ fTextHovers= new HashMap<>();
}
fTextHovers.put(key, hover);
} else if (fTextHovers != null)
@@ -2103,9 +2103,9 @@ public class TextViewer extends Viewer implements
if (fTextHovers == null)
return;
- Iterator iter= new HashSet(fTextHovers.keySet()).iterator();
+ Iterator<TextHoverKey> iter= new HashSet<>(fTextHovers.keySet()).iterator();
while (iter.hasNext()) {
- TextHoverKey key= (TextHoverKey)iter.next();
+ TextHoverKey key= iter.next();
if (key.fContentType.equals(contentType))
fTextHovers.remove(key);
}
@@ -2486,7 +2486,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fPostSelectionChangedListeners == null)
- fPostSelectionChangedListeners= new ArrayList();
+ fPostSelectionChangedListeners= new ArrayList<>();
if (!fPostSelectionChangedListeners.contains(listener))
fPostSelectionChangedListeners.add(listener);
@@ -2613,11 +2613,11 @@ public class TextViewer extends Viewer implements
* @since 3.0
*/
private void firePostSelectionChanged(SelectionChangedEvent event) {
- List listeners= fPostSelectionChangedListeners;
+ List<ISelectionChangedListener> listeners= fPostSelectionChangedListeners;
if (listeners != null) {
- listeners= new ArrayList(listeners);
+ listeners= new ArrayList<>(listeners);
for (int i= 0; i < listeners.size(); i++) {
- ISelectionChangedListener l= (ISelectionChangedListener) listeners.get(i);
+ ISelectionChangedListener l= listeners.get(i);
l.selectionChanged(event);
}
}
@@ -2654,7 +2654,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextListeners == null)
- fTextListeners= new ArrayList();
+ fTextListeners= new ArrayList<>();
if (!fTextListeners.contains(listener))
fTextListeners.add(listener);
@@ -2679,16 +2679,16 @@ public class TextViewer extends Viewer implements
* @param cmd the widget command translated into a text event sent to all text listeners
*/
protected void updateTextListeners(WidgetCommand cmd) {
- List textListeners= fTextListeners;
+ List<ITextListener> textListeners= fTextListeners;
if (textListeners != null) {
- textListeners= new ArrayList(textListeners);
+ textListeners= new ArrayList<>(textListeners);
DocumentEvent event= cmd.event;
if (event instanceof SlaveDocumentEvent)
event= ((SlaveDocumentEvent) event).getMasterEvent();
TextEvent e= new TextEvent(cmd.start, cmd.length, cmd.text, cmd.preservedText, event, redraws());
for (int i= 0; i < textListeners.size(); i++) {
- ITextListener l= (ITextListener) textListeners.get(i);
+ ITextListener l= textListeners.get(i);
l.textChanged(e);
}
}
@@ -2702,7 +2702,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextInputListeners == null)
- fTextInputListeners= new ArrayList();
+ fTextInputListeners= new ArrayList<>();
if (!fTextInputListeners.contains(listener))
fTextInputListeners.add(listener);
@@ -2728,10 +2728,10 @@ public class TextViewer extends Viewer implements
* @param newInput the new input document
*/
protected void fireInputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- List listener= fTextInputListeners;
+ List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= (ITextInputListener) listener.get(i);
+ ITextInputListener l= listener.get(i);
l.inputDocumentAboutToBeChanged(oldInput, newInput);
}
}
@@ -2745,10 +2745,10 @@ public class TextViewer extends Viewer implements
* @param newInput the new input document
*/
protected void fireInputDocumentChanged(IDocument oldInput, IDocument newInput) {
- List listener= fTextInputListeners;
+ List<ITextInputListener> listener= fTextInputListeners;
if (listener != null) {
for (int i= 0; i < listener.size(); i++) {
- ITextInputListener l= (ITextInputListener) listener.get(i);
+ ITextInputListener l= listener.get(i);
l.inputDocumentChanged(oldInput, newInput);
}
}
@@ -2937,7 +2937,7 @@ public class TextViewer extends Viewer implements
public void addViewportListener(IViewportListener listener) {
if (fViewportListeners == null) {
- fViewportListeners= new ArrayList();
+ fViewportListeners= new ArrayList<>();
initializeViewportUpdate();
}
@@ -2966,7 +2966,7 @@ public class TextViewer extends Viewer implements
if (topPixel >= 0 && topPixel != fLastTopPixel) {
if (fViewportListeners != null) {
for (int i= 0; i < fViewportListeners.size(); i++) {
- IViewportListener l= (IViewportListener) fViewportListeners.get(i);
+ IViewportListener l= fViewportListeners.get(i);
l.viewportChanged(topPixel);
}
}
@@ -3532,7 +3532,7 @@ public class TextViewer extends Viewer implements
if (strategy != null) {
if (fDoubleClickStrategies == null)
- fDoubleClickStrategies= new HashMap();
+ fDoubleClickStrategies= new HashMap<>();
fDoubleClickStrategies.put(contentType, strategy);
} else if (fDoubleClickStrategies != null)
fDoubleClickStrategies.remove(contentType);
@@ -3542,11 +3542,11 @@ public class TextViewer extends Viewer implements
* Selects from the given map the one which is registered under the content type of the
* partition in which the given offset is located.
*
- * @param plugins the map from which to choose
* @param offset the offset for which to find the plug-in
+ * @param plugins the map from which to choose
* @return the plug-in registered under the offset's content type or <code>null</code> if none
*/
- protected Object selectContentTypePlugin(int offset, Map plugins) {
+ protected Object selectContentTypePlugin(int offset, Map<String, ?> plugins) {
final IDocument document= getDocument();
if (document == null)
return null;
@@ -3567,7 +3567,7 @@ public class TextViewer extends Viewer implements
* @param plugins the table to be searched
* @return the plug-in in the map for the given content type
*/
- private Object selectContentTypePlugin(String type, Map plugins) {
+ private Object selectContentTypePlugin(String type, Map<String, ?> plugins) {
if (plugins == null)
return null;
@@ -3592,7 +3592,8 @@ public class TextViewer extends Viewer implements
if (fTabsToSpacesConverter != null)
fTabsToSpacesConverter.customizeDocumentCommand(document, command);
- List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
+ @SuppressWarnings("unchecked")
+ List<IAutoEditStrategy> strategies= (List<IAutoEditStrategy>) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
if (strategies == null)
return;
@@ -3602,14 +3603,14 @@ public class TextViewer extends Viewer implements
break;
case 1:
- ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(document, command);
+ strategies.iterator().next().customizeDocumentCommand(document, command);
break;
// make iterator robust against adding/removing strategies from within strategies
default:
- strategies= new ArrayList(strategies);
- for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); )
- ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command);
+ strategies= new ArrayList<>(strategies);
+ for (final Iterator<IAutoEditStrategy> iterator= strategies.iterator(); iterator.hasNext(); )
+ iterator.next().customizeDocumentCommand(document, command);
break;
}
@@ -4219,7 +4220,7 @@ public class TextViewer extends Viewer implements
fUndoManager.beginCompoundChange();
IDocument d= getDocument();
- Map partitioners= null;
+ Map<String, IDocumentPartitioner> partitioners= null;
DocumentRewriteSession rewriteSession= null;
try {
ITextSelection selection= (ITextSelection) getSelection();
@@ -4251,7 +4252,7 @@ public class TextViewer extends Viewer implements
partitioners= TextUtilities.removeDocumentPartitioners(d);
// Perform the shift operation.
- Map map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
+ Map<String, String[]> map= (useDefaultPrefixes ? fDefaultPrefixChars : fIndentChars);
for (int i= 0, j= 0; i < regions.length; i++, j += 2) {
String[] prefixes= (String[]) selectContentTypePlugin(regions[i].getType(), map);
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) {
@@ -4652,27 +4653,27 @@ public class TextViewer extends Viewer implements
if (range != null)
fTextWidget.setStyleRange(range);
- ArrayList ranges= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getNonDefaultStyleRangeIterator();
+ ArrayList<StyleRange> ranges= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getNonDefaultStyleRangeIterator();
while (e.hasNext()) {
- range= (StyleRange) e.next();
+ range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
ranges.add(range);
}
if (!ranges.isEmpty())
- fTextWidget.replaceStyleRanges(0, 0, (StyleRange[])ranges.toArray(new StyleRange[ranges.size()]));
+ fTextWidget.replaceStyleRanges(0, 0, ranges.toArray(new StyleRange[ranges.size()]));
} else {
IRegion region= modelRange2WidgetRange(presentation.getCoverage());
if (region == null)
return;
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
+ List<StyleRange> list= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- range= (StyleRange) e.next();
+ range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
list.add(range);
@@ -4694,10 +4695,10 @@ public class TextViewer extends Viewer implements
*/
private void applyTextPresentation(TextPresentation presentation) {
- List list= new ArrayList(presentation.getDenumerableRanges());
- Iterator e= presentation.getAllStyleRangeIterator();
+ List<StyleRange> list= new ArrayList<>(presentation.getDenumerableRanges());
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
+ StyleRange range= e.next();
range= modelStyleRange2WidgetStyleRange(range);
if (range != null)
list.add(range);
@@ -4742,9 +4743,9 @@ public class TextViewer extends Viewer implements
* and let them apply their presentation.
*/
if (fTextPresentationListeners != null) {
- ArrayList listeners= new ArrayList(fTextPresentationListeners);
+ ArrayList<ITextPresentationListener> listeners= new ArrayList<>(fTextPresentationListeners);
for (int i= 0, size= listeners.size(); i < size; i++) {
- ITextPresentationListener listener= (ITextPresentationListener)listeners.get(i);
+ ITextPresentationListener listener= listeners.get(i);
listener.applyTextPresentation(presentation);
}
}
@@ -5459,7 +5460,7 @@ public class TextViewer extends Viewer implements
Assert.isNotNull(listener);
if (fTextPresentationListeners == null)
- fTextPresentationListeners= new ArrayList();
+ fTextPresentationListeners= new ArrayList<>();
if (!fTextPresentationListeners.contains(listener))
fTextPresentationListeners.add(listener);
@@ -5502,7 +5503,7 @@ public class TextViewer extends Viewer implements
*/
@Override
public IEditingSupport[] getRegisteredSupports() {
- return (IEditingSupport[]) fEditorHelpers.toArray(new IEditingSupport[fEditorHelpers.size()]);
+ return fEditorHelpers.toArray(new IEditingSupport[fEditorHelpers.size()]);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index cb28c396118..697c52fbaf7 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.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
@@ -15,7 +15,6 @@ package org.eclipse.jface.text.contentassist;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.osgi.util.TextProcessor;
@@ -291,7 +290,7 @@ class CompletionProposalPopup implements IContentAssistListener {
/** The key listener to control navigation. */
private ProposalSelectionListener fKeyListener;
/** List of document events used for filtering proposals. */
- private final List fDocumentEvents= new ArrayList();
+ private final List<DocumentEvent> fDocumentEvents= new ArrayList<>();
/** Listener filling the document event queue. */
private IDocumentListener fDocumentListener;
/** The filter list of proposals. */
@@ -1509,7 +1508,7 @@ class CompletionProposalPopup implements IContentAssistListener {
IDocument document= fContentAssistSubjectControlAdapter.getDocument();
int length= proposals.length;
- List filtered= new ArrayList(length);
+ List<Object> filtered= new ArrayList<>(length);
for (int i= 0; i < length; i++) {
if (proposals[i] instanceof ICompletionProposalExtension2) {
@@ -1540,7 +1539,7 @@ class CompletionProposalPopup implements IContentAssistListener {
}
}
- return (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
+ return filtered.toArray(new ICompletionProposal[filtered.size()]);
}
/**
@@ -1658,7 +1657,7 @@ class CompletionProposalPopup implements IContentAssistListener {
// contains the common postfix in the case that there are any proposals matching our LHS
StringBuffer rightCasePostfix= null;
- List rightCase= new ArrayList();
+ List<ICompletionProposal> rightCase= new ArrayList<>();
boolean isWrongCaseMatch= false;
@@ -1668,7 +1667,7 @@ class CompletionProposalPopup implements IContentAssistListener {
int wrongCasePrefixStart= 0;
// contains the common postfix of all case-insensitive matches
StringBuffer wrongCasePostfix= null;
- List wrongCase= new ArrayList();
+ List<ICompletionProposal> wrongCase= new ArrayList<>();
for (int i= 0; i < fFilteredProposals.length; i++) {
ICompletionProposal proposal= fFilteredProposals[i];
@@ -1721,7 +1720,7 @@ class CompletionProposalPopup implements IContentAssistListener {
// 2: replace single proposals
if (rightCase.size() == 1) {
- ICompletionProposal proposal= (ICompletionProposal) rightCase.get(0);
+ ICompletionProposal proposal= rightCase.get(0);
if (canAutoInsert(proposal) && rightCasePostfix.length() > 0) {
insertProposal(proposal, (char) 0, 0, fInvocationOffset);
hide();
@@ -1729,7 +1728,7 @@ class CompletionProposalPopup implements IContentAssistListener {
}
return false;
} else if (isWrongCaseMatch && wrongCase.size() == 1) {
- ICompletionProposal proposal= (ICompletionProposal) wrongCase.get(0);
+ ICompletionProposal proposal= wrongCase.get(0);
if (canAutoInsert(proposal)) {
insertProposal(proposal, (char) 0, 0, fInvocationOffset);
hide();
@@ -1904,12 +1903,6 @@ class CompletionProposalPopup implements IContentAssistListener {
* @since 3.8
*/
private void sortProposals(final ICompletionProposal[] proposals) {
- Arrays.sort(proposals, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- return fSorter.compare((ICompletionProposal)o1,
- (ICompletionProposal)o2);
- }
- });
+ Arrays.sort(proposals, fSorter::compare);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
index 94f6c04436b..7fc5166fce3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.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
@@ -906,7 +906,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
private boolean fIsAutoInserting= false;
private int fProposalPopupOrientation= PROPOSAL_OVERLAY;
private int fContextInfoPopupOrientation= CONTEXT_INFO_ABOVE;
- private Map fProcessors;
+ private Map<String, IContentAssistProcessor> fProcessors;
/**
* The partitioning.
@@ -1023,7 +1023,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*
* @since 3.4
*/
- private Map fHandlers;
+ private Map<String, IHandler> fHandlers;
/**
* Tells whether colored labels support is enabled.
@@ -1080,7 +1080,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
Assert.isNotNull(contentType);
if (fProcessors == null)
- fProcessors= new HashMap();
+ fProcessors= new HashMap<>();
if (processor == null)
fProcessors.remove(contentType);
@@ -1096,7 +1096,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (fProcessors == null)
return null;
- return (IContentAssistProcessor) fProcessors.get(contentType);
+ return fProcessors.get(contentType);
}
/**
@@ -1110,10 +1110,10 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
return ""; //$NON-NLS-1$
StringBuffer buf= new StringBuffer(5);
- Iterator iter= fProcessors.entrySet().iterator();
+ Iterator<Entry<String, IContentAssistProcessor>> iter= fProcessors.entrySet().iterator();
while (iter.hasNext()) {
- Entry entry= (Entry) iter.next();
- IContentAssistProcessor processor= (IContentAssistProcessor) entry.getValue();
+ Entry<String, IContentAssistProcessor> entry= iter.next();
+ IContentAssistProcessor processor= entry.getValue();
char[] triggers= processor.getCompletionProposalAutoActivationCharacters();
if (triggers != null)
buf.append(triggers);
@@ -2535,7 +2535,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
if (fHandlers == null)
throw new IllegalStateException();
- IHandler handler= (IHandler)fHandlers.get(commandId);
+ IHandler handler= fHandlers.get(commandId);
if (handler != null)
return handler;
@@ -2552,7 +2552,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt
*/
protected final void registerHandler(String commandId, IHandler handler) {
if (fHandlers == null)
- fHandlers= new HashMap(2);
+ fHandlers= new HashMap<>(2);
fHandlers.put(commandId, handler);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index 0bc4eb0360b..600741249f0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.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
@@ -117,7 +117,7 @@ class ContextInformationPopup implements IContentAssistListener {
private StyledText fContextInfoText;
private TextPresentation fTextPresentation;
- private Stack fContextFrameStack= new Stack();
+ private Stack<ContextFrame> fContextFrameStack= new Stack<>();
/**
* The content assist subject control.
*
@@ -218,8 +218,8 @@ class ContextInformationPopup implements IContentAssistListener {
}
// also check all other contexts
- for (Iterator it= fContextFrameStack.iterator(); it.hasNext(); ) {
- ContextFrame stackFrame= (ContextFrame) it.next();
+ for (Iterator<ContextFrame> it= fContextFrameStack.iterator(); it.hasNext(); ) {
+ ContextFrame stackFrame= it.next();
if (stackFrame.equals(frame)) {
validateContextInformation();
return;
@@ -321,7 +321,7 @@ class ContextInformationPopup implements IContentAssistListener {
if (fContextFrameStack.isEmpty())
return false;
// stack not empty
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame top= fContextFrameStack.peek();
return frame.equals(top);
}
@@ -460,12 +460,12 @@ class ContextInformationPopup implements IContentAssistListener {
int size= fContextFrameStack.size();
if (size > 0) {
- fLastContext= (ContextFrame) fContextFrameStack.pop();
+ fLastContext= fContextFrameStack.pop();
-- size;
}
if (size > 0) {
- ContextFrame current= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame current= fContextFrameStack.peek();
internalShowContextFrame(current, false);
} else {
@@ -872,7 +872,7 @@ class ContextInformationPopup implements IContentAssistListener {
fContextInfoPopup.getDisplay().asyncExec(new Runnable() {
- private ContextFrame fFrame= (ContextFrame) fContextFrameStack.peek();
+ private ContextFrame fFrame= fContextFrameStack.peek();
@Override
public void run() {
@@ -882,7 +882,7 @@ class ContextInformationPopup implements IContentAssistListener {
// iterate all contexts on the stack
while (Helper.okToUse(fContextInfoPopup) && !fContextFrameStack.isEmpty()) {
- ContextFrame top= (ContextFrame) fContextFrameStack.peek();
+ ContextFrame top= fContextFrameStack.peek();
if (top.fValidator == null || !top.fValidator.isContextInformationValid(offset)) {
hideContextInfoPopup(); // loop variant: reduces the number of contexts on the stack
} else if (top.fPresenter != null && top.fPresenter.updatePresentation(offset, fTextPresentation)) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
index e02b999a493..fd0d9b8ddc4 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContentFormatter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 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
@@ -69,7 +69,7 @@ public class ContentFormatter implements IContentFormatter {
* Defines a reference to either the offset or the end offset of
* a particular position.
*/
- static class PositionReference implements Comparable {
+ static class PositionReference implements Comparable<PositionReference> {
/** The referenced position */
protected Position fPosition;
@@ -167,14 +167,8 @@ public class ContentFormatter implements IContentFormatter {
}
@Override
- public int compareTo(Object obj) {
-
- if (obj instanceof PositionReference) {
- PositionReference r= (PositionReference) obj;
- return getCharacterPosition() - r.getCharacterPosition();
- }
-
- throw new ClassCastException();
+ public int compareTo(PositionReference r) {
+ return getCharacterPosition() - r.getCharacterPosition();
}
}
@@ -251,14 +245,14 @@ public class ContentFormatter implements IContentFormatter {
private final static String PARTITIONING= "__formatter_partitioning"; //$NON-NLS-1$
/** The map of <code>IFormattingStrategy</code> objects */
- private Map fStrategies;
+ private Map<String, IFormattingStrategy> fStrategies;
/** The indicator of whether the formatter operates in partition aware mode or not */
private boolean fIsPartitionAware= true;
/** The partition information managing document position categories */
private String[] fPartitionManagingCategories;
/** The list of references to offset and end offset of all overlapping positions */
- private List fOverlappingPositionReferences;
+ private List<PositionReference> fOverlappingPositionReferences;
/** Position updater used for partitioning positions */
private IPositionUpdater fPartitioningUpdater;
/**
@@ -306,7 +300,7 @@ public class ContentFormatter implements IContentFormatter {
Assert.isNotNull(contentType);
if (fStrategies == null)
- fStrategies= new HashMap();
+ fStrategies= new HashMap<>();
if (strategy == null)
fStrategies.remove(contentType);
@@ -355,7 +349,7 @@ public class ContentFormatter implements IContentFormatter {
if (fStrategies == null)
return null;
- return (IFormattingStrategy) fStrategies.get(contentType);
+ return fStrategies.get(contentType);
}
@Override
@@ -657,7 +651,7 @@ public class ContentFormatter implements IContentFormatter {
*/
private int[] getAffectedPositions(int offset, int length) {
- fOverlappingPositionReferences= new ArrayList();
+ fOverlappingPositionReferences= new ArrayList<>();
determinePositionsToUpdate(offset, length);
@@ -665,7 +659,7 @@ public class ContentFormatter implements IContentFormatter {
int[] positions= new int[fOverlappingPositionReferences.size()];
for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
positions[i]= r.getCharacterPosition() - offset;
}
@@ -681,7 +675,7 @@ public class ContentFormatter implements IContentFormatter {
private void removeAffectedPositions(IDocument document) {
int size= fOverlappingPositionReferences.size();
for (int i= 0; i < size; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
try {
document.removePosition(r.getCategory(), r.getPosition());
} catch (BadPositionCategoryException x) {
@@ -708,7 +702,7 @@ public class ContentFormatter implements IContentFormatter {
for (int i= 0; i < positions.length; i++) {
- PositionReference r= (PositionReference) fOverlappingPositionReferences.get(i);
+ PositionReference r= fOverlappingPositionReferences.get(i);
if (r.refersToOffset())
r.setOffset(offset + positions[i]);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
index ddeccc8d140..65342636d28 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/ContextBasedFormattingStrategy.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
@@ -25,14 +25,14 @@ import java.util.Map;
public abstract class ContextBasedFormattingStrategy implements IFormattingStrategy, IFormattingStrategyExtension {
/** The current preferences for formatting */
- private Map fCurrentPreferences= null;
+ private Map<String, String> fCurrentPreferences= null;
/** The list of preferences for initiated the formatting steps */
- private final LinkedList fPreferences= new LinkedList();
+ private final LinkedList<Map<String, String>> fPreferences= new LinkedList<>();
@Override
public void format() {
- fCurrentPreferences= (Map)fPreferences.removeFirst();
+ fCurrentPreferences= fPreferences.removeFirst();
}
@Override
@@ -42,7 +42,9 @@ public abstract class ContextBasedFormattingStrategy implements IFormattingStrat
@Override
public void formatterStarts(final IFormattingContext context) {
- fPreferences.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES));
+ @SuppressWarnings("unchecked")
+ Map<String, String> prefs= (Map<String, String>) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES);
+ fPreferences.addLast(prefs);
}
@Override
@@ -62,7 +64,7 @@ public abstract class ContextBasedFormattingStrategy implements IFormattingStrat
*
* @return The preferences for the current formatting step
*/
- public final Map getPreferences() {
+ public final Map<String, String> getPreferences() {
return fCurrentPreferences;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
index 9b76ced365e..adce0392947 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContext.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
@@ -24,7 +24,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
public class FormattingContext implements IFormattingContext {
/** Map to store the properties */
- private final Map fMap= new HashMap();
+ private final Map<Object, Object> fMap= new HashMap<>();
@Override
public void dispose() {
@@ -73,7 +73,7 @@ public class FormattingContext implements IFormattingContext {
}
@Override
- public void mapToStore(Map map, IPreferenceStore store) {
+ public void mapToStore(Map<Object, Object> map, IPreferenceStore store) {
final String[] preferences= getPreferenceKeys();
@@ -114,7 +114,7 @@ public class FormattingContext implements IFormattingContext {
}
@Override
- public void storeToMap(IPreferenceStore store, Map map, boolean useDefault) {
+ public void storeToMap(IPreferenceStore store, Map<Object, Object> map, boolean useDefault) {
final String[] preferences= getPreferenceKeys();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
index 662b1d0f2c5..27fa75a3003 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/FormattingContextProperties.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
@@ -42,8 +42,8 @@ public class FormattingContextProperties {
public static final String CONTEXT_PARTITION= "formatting.context.partition"; //$NON-NLS-1$
/**
- * Property key of the preferences property. The property must implement
- * <code>java.util#Map</code>. The formatting preferences mapping preference
+ * Property key of the preferences property. The property value must implement
+ * {@code java.util.Map<String, String>}. The formatting preferences mapping preference
* keys to values.
* <p>
* Value: <code>"formatting.context.preferences"</code>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
index fa92119d1c7..616c1e2f990 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/IFormattingContext.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
@@ -41,7 +41,7 @@ public interface IFormattingContext {
/**
* Retrieves the property <code>key</code> from the formatting context
*
- * @param key the key of the property to store in the context
+ * @param key the key of the property to store in the context. Must be a {@link String}.
* @return the property <code>key</code> if available, <code>null</code> otherwise
*/
Object getProperty(Object key);
@@ -110,12 +110,12 @@ public interface IFormattingContext {
* @param map Map to retrieve the preferences from
* @param store Preference store to store the preferences in
*/
- void mapToStore(Map map, IPreferenceStore store);
+ void mapToStore(Map<Object, Object> map, IPreferenceStore store);
/**
* Stores the property <code>key</code> in the formatting context.
*
- * @param key Key of the property to store in the context
+ * @param key Key of the property to store in the context. Must be a {@link String}.
* @param property Property to store in the context. If already present, the new property
* overwrites the present one.
*/
@@ -133,5 +133,5 @@ public interface IFormattingContext {
* @param useDefault <code>true</code> if the default preferences should be used,
* <code>false</code> otherwise
*/
- void storeToMap(IPreferenceStore store, Map map, boolean useDefault);
+ void storeToMap(IPreferenceStore store, Map<Object, Object> map, boolean useDefault);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
index be8d549897c..7abacbb4a89 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/formatter/MultiPassContentFormatter.java
@@ -20,6 +20,7 @@ import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
@@ -103,7 +104,7 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
/** The partitioning of this content formatter */
private final String fPartitioning;
/** The slave formatting strategies */
- private final Map fSlaves= new HashMap();
+ private final Map<String, IFormattingStrategy> fSlaves= new HashMap<>();
/** The default content type */
private final String fType;
@@ -240,7 +241,7 @@ public class MultiPassContentFormatter implements IContentFormatter, IContentFor
*/
protected void formatSlaves(final IFormattingContext context, final IDocument document, final int offset, final int length) {
- Map partitioners= new HashMap(0);
+ Map<String, IDocumentPartitioner> partitioners= new HashMap<>(0);
try {
final ITypedRegion[] partitions= TextUtilities.computePartitioning(document, fPartitioning, offset, length, false);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
index cd73b4f4480..56684a0baf5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/AbstractHyperlinkDetector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
+ * Copyright (c) 2007, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -60,7 +60,7 @@ public abstract class AbstractHyperlinkDetector implements IHyperlinkDetector, I
* or <code>null</code> if this object does not
* have an adapter for the given class
*/
- protected final Object getAdapter(Class adapterClass) {
+ protected final <T> T getAdapter(Class<T> adapterClass) {
Assert.isLegal(adapterClass != null);
if (fContext != null)
return fContext.getAdapter(adapterClass);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
index 419e4bb0bf2..e38a970cf2d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/hyperlink/HyperlinkManager.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
@@ -267,7 +267,7 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
* @since 3.7
*/
private IHyperlink[] findHyperlinks(IRegion region) {
- List allHyperlinks= new ArrayList(fHyperlinkDetectors.length * 2);
+ List<IHyperlink> allHyperlinks= new ArrayList<>(fHyperlinkDetectors.length * 2);
synchronized (fHyperlinkDetectors) {
for (int i= 0, length= fHyperlinkDetectors.length; i < length; i++) {
IHyperlinkDetector detector= fHyperlinkDetectors[i];
@@ -304,18 +304,18 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
if (fDetectionStrategy != ALL) {
int maxLength= computeLongestHyperlinkLength(allHyperlinks);
- Iterator iter= new ArrayList(allHyperlinks).iterator();
+ Iterator<IHyperlink> iter= new ArrayList<>(allHyperlinks).iterator();
while (iter.hasNext()) {
- IHyperlink hyperlink= (IHyperlink)iter.next();
+ IHyperlink hyperlink= iter.next();
if (hyperlink.getHyperlinkRegion().getLength() < maxLength)
allHyperlinks.remove(hyperlink);
}
}
if (fDetectionStrategy == LONGEST_REGION_FIRST)
- return new IHyperlink[] {(IHyperlink)allHyperlinks.get(0)};
+ return new IHyperlink[] {allHyperlinks.get(0)};
- return (IHyperlink[])allHyperlinks.toArray(new IHyperlink[allHyperlinks.size()]);
+ return allHyperlinks.toArray(new IHyperlink[allHyperlinks.size()]);
}
@@ -325,12 +325,12 @@ public class HyperlinkManager implements ITextListener, Listener, KeyListener, M
* @param hyperlinks the list of hyperlinks
* @return the length of the longest detected
*/
- protected int computeLongestHyperlinkLength(List hyperlinks) {
+ protected int computeLongestHyperlinkLength(List<? extends IHyperlink> hyperlinks) {
Assert.isLegal(hyperlinks != null && !hyperlinks.isEmpty());
- Iterator iter= hyperlinks.iterator();
+ Iterator<? extends IHyperlink> iter= hyperlinks.iterator();
int length= Integer.MIN_VALUE;
while (iter.hasNext()) {
- IRegion region= ((IHyperlink)iter.next()).getHyperlinkRegion();
+ IRegion region= iter.next().getHyperlinkRegion();
if (region.getLength() < length)
continue;
length= region.getLength();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
index c9c73534e47..45e927dc274 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/information/InformationPresenter.java
@@ -200,7 +200,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
/** The text viewer this information presenter works on */
private ITextViewer fTextViewer;
/** The map of <code>IInformationProvider</code> objects */
- private Map fProviders;
+ private Map<String, IInformationProvider> fProviders;
/** The offset to override selection. */
private int fOffset= -1;
/**
@@ -256,7 +256,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
Assert.isNotNull(contentType);
if (fProviders == null)
- fProviders= new HashMap();
+ fProviders= new HashMap<>();
if (provider == null)
fProviders.remove(contentType);
@@ -269,7 +269,7 @@ public class InformationPresenter extends AbstractInformationControlManager impl
if (fProviders == null)
return null;
- return (IInformationProvider) fProviders.get(contentType);
+ return fProviders.get(contentType);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index 4f2a5492d0c..40cf26cd61e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -1043,12 +1043,12 @@ public class LinkedModeUI {
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 ext= (IDocumentExtension3) document;
String[] partitionings= ext.getPartitionings();
- Set contentTypes= new HashSet(20);
+ Set<String> contentTypes= new HashSet<>(20);
for (int i= 0; i < partitionings.length; i++) {
contentTypes.addAll(Arrays.asList(ext.getLegalContentTypes(partitionings[i])));
}
contentTypes.add(IDocument.DEFAULT_CONTENT_TYPE);
- return (String[]) contentTypes.toArray(new String[contentTypes.size()]);
+ return contentTypes.toArray(new String[contentTypes.size()]);
}
return document.getLegalContentTypes();
}
@@ -1149,7 +1149,7 @@ public class LinkedModeUI {
if ((flags & ILinkedModeListener.UPDATE_CARET) != 0 && fExitPosition != null && fFramePosition != fExitPosition && !fExitPosition.isDeleted())
switchPosition(fExitPosition, true, false);
- final List docs= new ArrayList();
+ final List<IDocument> docs= new ArrayList<>();
for (int i= 0; i < fTargets.length; i++) {
IDocument doc= fTargets[i].getViewer().getDocument();
if (doc != null)
@@ -1164,8 +1164,8 @@ public class LinkedModeUI {
if (fExitPosition != null)
fExitPosition.getDocument().removePosition(fExitPosition);
- for (Iterator iter = docs.iterator(); iter.hasNext(); ) {
- IDocument doc= (IDocument) iter.next();
+ for (Iterator<IDocument> iter = docs.iterator(); iter.hasNext(); ) {
+ IDocument doc= iter.next();
doc.removePositionUpdater(fPositionUpdater);
boolean uninstallCat= false;
String[] cats= doc.getPositionCategories();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
index b379b88ca4c..297afa7d8d8 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedPositionAnnotations.java
@@ -46,8 +46,8 @@ final class LinkedPositionAnnotations extends AnnotationModel {
private Annotation fFocusAnnotation= null;
private Annotation fExitAnnotation= null;
- private final Map fGroupAnnotations= new HashMap();
- private final Map fTargetAnnotations= new HashMap();
+ private final Map<Position, Annotation> fGroupAnnotations= new HashMap<>();
+ private final Map<Position, Annotation> fTargetAnnotations= new HashMap<>();
private Position[] fTargets= new Position[0];
private LinkedPosition fExitPosition= null;
@@ -96,7 +96,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
* @param positions the new slave positions, or <code>null</code> if no slave positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
- private void setGroupPositions(List positions) throws BadLocationException {
+ private void setGroupPositions(List<Position> positions) throws BadLocationException {
if (!fMarkSlaves)
return;
@@ -104,11 +104,11 @@ final class LinkedPositionAnnotations extends AnnotationModel {
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fGroupAnnotations.values());
- Map toAdd= new HashMap();
+ List<Annotation> toRemove= new ArrayList<>(fGroupAnnotations.values());
+ Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
+ for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
+ Position p= iter.next();
if (fGroupAnnotations.containsKey(p)) {
toRemove.remove(fGroupAnnotations.get(p));
} else {
@@ -120,7 +120,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
}
fGroupAnnotations.values().removeAll(toRemove);
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
+ replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
/**
@@ -130,7 +130,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
* @param positions the new target positions, or <code>null</code> if no target positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
- private void setTargetPositions(List positions) throws BadLocationException {
+ private void setTargetPositions(List<Position> positions) throws BadLocationException {
if (!fMarkTargets)
return;
@@ -138,11 +138,11 @@ final class LinkedPositionAnnotations extends AnnotationModel {
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
- List toRemove= new ArrayList(fTargetAnnotations.values());
- Map toAdd= new HashMap();
+ List<Annotation> toRemove= new ArrayList<>(fTargetAnnotations.values());
+ Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
- for (Iterator iter= positions.iterator(); iter.hasNext();) {
- Position p= (Position) iter.next();
+ for (Iterator<Position> iter= positions.iterator(); iter.hasNext();) {
+ Position p= iter.next();
if (fTargetAnnotations.containsKey(p)) {
toRemove.remove(fTargetAnnotations.get(p));
} else {
@@ -154,7 +154,7 @@ final class LinkedPositionAnnotations extends AnnotationModel {
}
fTargetAnnotations.values().removeAll(toRemove);
- replaceAnnotations((Annotation[]) toRemove.toArray(new Annotation[0]), toAdd, false);
+ replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
/**
@@ -175,14 +175,14 @@ final class LinkedPositionAnnotations extends AnnotationModel {
if (position != null)
linkedGroup= env.getGroupForPosition(position);
- List targets= new ArrayList();
+ List<Position> targets= new ArrayList<>();
targets.addAll(Arrays.asList(fTargets));
- List group;
+ List<Position> group;
if (linkedGroup != null)
- group= new ArrayList(Arrays.asList(linkedGroup.getPositions()));
+ group= new ArrayList<>(Arrays.asList(linkedGroup.getPositions()));
else
- group= new ArrayList();
+ group= new ArrayList<>();
if (position == null || !fDocument.equals(position.getDocument()))
// position is not valid if not in this document
@@ -225,8 +225,8 @@ final class LinkedPositionAnnotations extends AnnotationModel {
*
* @param list the list of positions to prune
*/
- private void prune(List list) {
- for (Iterator iter= list.iterator(); iter.hasNext();) {
+ private void prune(List<Position> list) {
+ for (Iterator<Position> iter= list.iterator(); iter.hasNext();) {
LinkedPosition pos= (LinkedPosition) iter.next();
if (!pos.getDocument().equals(fDocument))
iter.remove();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
index e45acee3371..bfcdaea8922 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/TabStopIterator.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
@@ -36,18 +36,10 @@ class TabStopIterator {
* Comparator for <code>LinkedPosition</code>s. If the sequence number of two positions is equal, the
* offset is used.
*/
- private static class SequenceComparator implements Comparator {
-
- /**
- * {@inheritDoc}
- *
- * <p><code>o1</code> and <code>o2</code> are required to be instances
- * of <code>LinkedPosition</code>.</p>
- */
+ private static class SequenceComparator implements Comparator<LinkedPosition> {
+
@Override
- public int compare(Object o1, Object o2) {
- LinkedPosition p1= (LinkedPosition)o1;
- LinkedPosition p2= (LinkedPosition)o2;
+ public int compare(LinkedPosition p1, LinkedPosition p2) {
int i= p1.getSequenceNumber() - p2.getSequenceNumber();
if (i != 0)
return i;
@@ -57,10 +49,10 @@ class TabStopIterator {
}
/** The comparator to sort the list of positions. */
- private static final Comparator fComparator= new SequenceComparator();
+ private static final Comparator<LinkedPosition> fComparator= new SequenceComparator();
/** The iteration sequence. */
- private final ArrayList fList;
+ private final ArrayList<LinkedPosition> fList;
/** The size of <code>fList</code>. */
private int fSize;
/** Index of the current element, to the first one initially. */
@@ -68,9 +60,9 @@ class TabStopIterator {
/** Cycling property. */
private boolean fIsCycling= false;
- TabStopIterator(List positionSequence) {
+ TabStopIterator(List<LinkedPosition> positionSequence) {
Assert.isNotNull(positionSequence);
- fList= new ArrayList(positionSequence);
+ fList= new ArrayList<>(positionSequence);
Collections.sort(fList, fComparator);
fSize= fList.size();
fIndex= -1;
@@ -113,8 +105,8 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
+ for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
+ LinkedPosition p= it.next();
if (p.offset > current.offset)
if (found == null || found.offset > p.offset)
found= p;
@@ -163,8 +155,8 @@ class TabStopIterator {
// find the position that follows closest to the current position
LinkedPosition found= null;
- for (Iterator it= fList.iterator(); it.hasNext(); ) {
- LinkedPosition p= (LinkedPosition) it.next();
+ for (Iterator<LinkedPosition> it= fList.iterator(); it.hasNext(); ) {
+ LinkedPosition p= it.next();
if (p.offset < current.offset)
if (found == null || found.offset < p.offset)
found= p;
@@ -180,20 +172,20 @@ class TabStopIterator {
LinkedPosition next(LinkedPosition current) {
if (!hasNext(current))
throw new NoSuchElementException();
- return (LinkedPosition) fList.get(fIndex= getNextIndex(current));
+ return fList.get(fIndex= getNextIndex(current));
}
LinkedPosition previous(LinkedPosition current) {
if (!hasPrevious(current))
throw new NoSuchElementException();
- return (LinkedPosition) fList.get(fIndex= getPreviousIndex(current));
+ return fList.get(fIndex= getPreviousIndex(current));
}
void setCycling(boolean mode) {
fIsCycling= mode;
}
- void addPosition(Position position) {
+ void addPosition(LinkedPosition position) {
fList.add(fSize++, position);
Collections.sort(fList, fComparator);
}
@@ -211,6 +203,6 @@ class TabStopIterator {
}
LinkedPosition[] getPositions() {
- return (LinkedPosition[]) fList.toArray(new LinkedPosition[fSize]);
+ return fList.toArray(new LinkedPosition[fSize]);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
index d530446456b..5fe6030a56f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/presentation/PresentationReconciler.java
@@ -240,9 +240,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
}
/** The map of presentation damagers. */
- private Map fDamagers;
+ private Map<String, IPresentationDamager> fDamagers;
/** The map of presentation repairers. */
- private Map fRepairers;
+ private Map<String, IPresentationRepairer> fRepairers;
/** The target viewer. */
private ITextViewer fViewer;
/** The internal listener. */
@@ -308,7 +308,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
Assert.isNotNull(contentType);
if (fDamagers == null)
- fDamagers= new HashMap();
+ fDamagers= new HashMap<>();
if (damager == null)
fDamagers.remove(contentType);
@@ -329,7 +329,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
Assert.isNotNull(contentType);
if (fRepairers == null)
- fRepairers= new HashMap();
+ fRepairers= new HashMap<>();
if (repairer == null)
fRepairers.remove(contentType);
@@ -363,7 +363,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
if (fDamagers == null)
return null;
- return (IPresentationDamager) fDamagers.get(contentType);
+ return fDamagers.get(contentType);
}
@Override
@@ -372,7 +372,7 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
if (fRepairers == null)
return null;
- return (IPresentationRepairer) fRepairers.get(contentType);
+ return fRepairers.get(contentType);
}
/**
@@ -382,9 +382,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
*/
protected void setDocumentToDamagers(IDocument document) {
if (fDamagers != null) {
- Iterator e= fDamagers.values().iterator();
+ Iterator<IPresentationDamager> e= fDamagers.values().iterator();
while (e.hasNext()) {
- IPresentationDamager damager= (IPresentationDamager) e.next();
+ IPresentationDamager damager= e.next();
damager.setDocument(document);
}
}
@@ -397,9 +397,9 @@ public class PresentationReconciler implements IPresentationReconciler, IPresent
*/
protected void setDocumentToRepairers(IDocument document) {
if (fRepairers != null) {
- Iterator e= fRepairers.values().iterator();
+ Iterator<IPresentationRepairer> e= fRepairers.values().iterator();
while (e.hasNext()) {
- IPresentationRepairer repairer= (IPresentationRepairer) e.next();
+ IPresentationRepairer repairer= e.next();
repairer.setDocument(document);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
index 111607fd63d..8e1fec14504 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconcileStep.java
@@ -132,9 +132,9 @@ public abstract class AbstractReconcileStep implements IReconcileStep {
return results1;
// XXX: not yet performance optimized
- Collection collection= new ArrayList(Arrays.asList(results1));
+ Collection<IReconcileResult> collection= new ArrayList<>(Arrays.asList(results1));
collection.addAll(Arrays.asList(results2));
- return (IReconcileResult[])collection.toArray(new IReconcileResult[collection.size()]);
+ return collection.toArray(new IReconcileResult[collection.size()]);
}
/*
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
index bd0ff409802..abce516458f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/DirtyRegionQueue.java
@@ -25,7 +25,7 @@ import java.util.List;
class DirtyRegionQueue {
/** The list of dirty regions. */
- private List fDirtyRegions= new ArrayList();
+ private List<DirtyRegion> fDirtyRegions= new ArrayList<>();
/**
* Creates a new empty dirty region.
@@ -70,7 +70,7 @@ class DirtyRegionQueue {
*/
private DirtyRegion getLastDirtyRegion() {
int size= fDirtyRegions.size();
- return (size == 0 ? null : (DirtyRegion) fDirtyRegions.get(size - 1));
+ return (size == 0 ? null : fDirtyRegions.get(size - 1));
}
/**
@@ -97,7 +97,7 @@ class DirtyRegionQueue {
public DirtyRegion removeNextDirtyRegion() {
if (fDirtyRegions.size() == 0)
return null;
- DirtyRegion dr= (DirtyRegion) fDirtyRegions.get(0);
+ DirtyRegion dr= fDirtyRegions.get(0);
fDirtyRegions.remove(0);
return dr;
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
index 4ff26dd2238..39ba8881cb5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/Reconciler.java
@@ -44,7 +44,7 @@ import org.eclipse.jface.text.TypedRegion;
public class Reconciler extends AbstractReconciler implements IReconcilerExtension {
/** The map of reconciling strategies. */
- private Map fStrategies;
+ private Map<String, IReconcilingStrategy> fStrategies;
/**
* The partitioning this reconciler uses.
@@ -92,7 +92,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
Assert.isNotNull(contentType);
if (fStrategies == null)
- fStrategies= new HashMap();
+ fStrategies= new HashMap<>();
if (strategy == null)
fStrategies.remove(contentType);
@@ -113,7 +113,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
if (fStrategies == null)
return null;
- return (IReconcilingStrategy) fStrategies.get(contentType);
+ return fStrategies.get(contentType);
}
/**
@@ -151,9 +151,9 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
@Override
protected void reconcilerDocumentChanged(IDocument document) {
if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
+ Iterator<IReconcilingStrategy> e= fStrategies.values().iterator();
while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
+ IReconcilingStrategy strategy= e.next();
strategy.setDocument(document);
}
}
@@ -164,9 +164,9 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
super.setProgressMonitor(monitor);
if (fStrategies != null) {
- Iterator e= fStrategies.values().iterator();
+ Iterator<IReconcilingStrategy> e= fStrategies.values().iterator();
while (e.hasNext()) {
- IReconcilingStrategy strategy= (IReconcilingStrategy) e.next();
+ IReconcilingStrategy strategy= e.next();
if (strategy instanceof IReconcilingStrategyExtension) {
IReconcilingStrategyExtension extension= (IReconcilingStrategyExtension) strategy;
extension.setProgressMonitor(monitor);
@@ -178,7 +178,7 @@ public class Reconciler extends AbstractReconciler implements IReconcilerExtensi
@Override
protected void initialProcess() {
ITypedRegion[] regions= computePartitioning(0, getDocument().getLength());
- List contentTypes= new ArrayList(regions.length);
+ List<String> contentTypes= new ArrayList<>(regions.length);
for (int i= 0; i < regions.length; i++) {
String contentType= regions[i].getType();
if( contentTypes.contains(contentType))
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
index 9765150f933..9a69d52642d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/Revision.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
@@ -20,6 +20,7 @@ import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.internal.text.revisions.ChangeRegion;
import org.eclipse.jface.internal.text.revisions.Hunk;
+import org.eclipse.jface.internal.text.revisions.Range;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.source.ILineRange;
@@ -33,15 +34,15 @@ import org.eclipse.jface.text.source.ILineRange;
* @since 3.2
*/
public abstract class Revision {
- /** The original list of change regions, element type: {@link ChangeRegion}. */
- private final List fChangeRegions= new ArrayList();
+ /** The original list of change regions. */
+ private final List<ChangeRegion> fChangeRegions= new ArrayList<>();
/**
- * The cached list of adjusted ranges, element type: {@link RevisionRange}. <code>null</code>
+ * The cached list of adjusted ranges. <code>null</code>
* if the list must be re-computed. Unmodifiable.
*
* @since 3.3
*/
- private List fRanges= null;
+ private List<RevisionRange> fRanges= null;
/**
* Creates a new revision.
@@ -65,15 +66,15 @@ public abstract class Revision {
* information is only valid at the moment it is returned, and may change as the annotated
* document is modified.
*
- * @return an unmodifiable view of the contained ranges (element type: {@link RevisionRange})
+ * @return an unmodifiable view of the contained ranges
*/
- public final List getRegions() {
+ public final List<RevisionRange> getRegions() {
if (fRanges == null) {
- List ranges= new ArrayList(fChangeRegions.size());
- for (Iterator it= fChangeRegions.iterator(); it.hasNext();) {
- ChangeRegion region= (ChangeRegion) it.next();
- for (Iterator inner= region.getAdjustedRanges().iterator(); inner.hasNext();) {
- ILineRange range= (ILineRange) inner.next();
+ List<RevisionRange> ranges= new ArrayList<>(fChangeRegions.size());
+ for (Iterator<ChangeRegion> it= fChangeRegions.iterator(); it.hasNext();) {
+ ChangeRegion region= it.next();
+ for (Iterator<Range> inner= region.getAdjustedRanges().iterator(); inner.hasNext();) {
+ ILineRange range= inner.next();
ranges.add(new RevisionRange(this, range));
}
}
@@ -91,8 +92,8 @@ public abstract class Revision {
*/
final void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator regions= fChangeRegions.iterator(); regions.hasNext();) {
- ChangeRegion region= (ChangeRegion) regions.next();
+ for (Iterator<ChangeRegion> regions= fChangeRegions.iterator(); regions.hasNext();) {
+ ChangeRegion region= regions.next();
region.clearDiff();
for (int i= 0; i < hunks.length; i++) {
Hunk hunk= hunks[i];
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
index 42f04a2bed8..aaf5656c653 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/revisions/RevisionInformation.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
@@ -12,7 +12,6 @@ package org.eclipse.jface.text.revisions;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
@@ -34,17 +33,17 @@ import org.eclipse.jface.text.information.IInformationProviderExtension2;
* @see Revision
*/
public final class RevisionInformation implements ITextHoverExtension, IInformationProviderExtension2 {
- /** The revisions, element type: {@link Revision}. */
- private final List fRevisions= new ArrayList();
+ /** The revisions. */
+ private final List<Revision> fRevisions= new ArrayList<>();
/** A unmodifiable view of <code>fRevisions</code>. */
- private final List fRORevisions= Collections.unmodifiableList(fRevisions);
+ private final List<Revision> fRORevisions= Collections.unmodifiableList(fRevisions);
/**
* The flattened list of {@link RevisionRange}s, unmodifiable. <code>null</code> if the list
* must be re-computed.
*
* @since 3.3
*/
- private List fRanges= null;
+ private List<RevisionRange> fRanges= null;
/**
* The hover control creator. Can be <code>null</code>.
@@ -79,9 +78,9 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
/**
* Returns the contained revisions.
*
- * @return an unmodifiable view of the contained revisions (element type: {@link Revision})
+ * @return an unmodifiable view of the contained revisions
*/
- public List getRevisions() {
+ public List<Revision> getRevisions() {
return fRORevisions;
}
@@ -91,28 +90,20 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
* {@link IRevisionListener} for a way to be informed when the revision information changes. The
* returned list is sorted by document offset.
*
- * @return an unmodifiable view of the line ranges (element type: {@link RevisionRange})
+ * @return an unmodifiable view of the line ranges
* @see IRevisionListener
* @since 3.3
*/
- public List getRanges() {
+ public List<RevisionRange> getRanges() {
if (fRanges == null) {
- List ranges= new ArrayList(fRevisions.size() * 2); // wild size guess
- for (Iterator it= fRevisions.iterator(); it.hasNext();) {
- Revision revision= (Revision) it.next();
+ List<RevisionRange> ranges= new ArrayList<>(fRevisions.size() * 2); // wild size guess
+ for (Iterator<Revision> it= fRevisions.iterator(); it.hasNext();) {
+ Revision revision= it.next();
ranges.addAll(revision.getRegions());
}
// sort by start line
- Collections.sort(ranges, new Comparator() {
- @Override
- public int compare(Object o1, Object o2) {
- RevisionRange r1= (RevisionRange) o1;
- RevisionRange r2= (RevisionRange) o2;
-
- return r1.getStartLine() - r2.getStartLine();
- }
- });
+ Collections.sort(ranges, (r1, r2) -> r1.getStartLine() - r2.getStartLine());
fRanges= Collections.unmodifiableList(ranges);
}
@@ -130,8 +121,8 @@ public final class RevisionInformation implements ITextHoverExtension, IInformat
*/
public void applyDiff(Hunk[] hunks) {
fRanges= null; // mark for recomputation
- for (Iterator revisions= getRevisions().iterator(); revisions.hasNext();)
- ((Revision) revisions.next()).applyDiff(hunks);
+ for (Iterator<Revision> revisions= getRevisions().iterator(); revisions.hasNext();)
+ revisions.next().applyDiff(hunks);
}
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
index 210e6bacddb..7c8cdb1e2a4 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/DefaultPartitioner.java
@@ -537,7 +537,7 @@ public class DefaultPartitioner implements IDocumentPartitioner, IDocumentPartit
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
checkInitialization();
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
index cb2937ec8a5..63e5251ec81 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/FastPartitioner.java
@@ -613,7 +613,7 @@ public class FastPartitioner implements IDocumentPartitioner, IDocumentPartition
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
checkInitialization();
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
index bb9ffa87090..4f8cf94120f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.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
@@ -33,10 +33,10 @@ public class PatternRule implements IPredicateRule {
*
* @since 3.1
*/
- private static class DecreasingCharArrayLengthComparator implements Comparator {
+ private static class DecreasingCharArrayLengthComparator implements Comparator<char[]> {
@Override
- public int compare(Object o1, Object o2) {
- return ((char[]) o2).length - ((char[]) o1).length;
+ public int compare(char[] o1, char[] o2) {
+ return o2.length - o1.length;
}
}
@@ -67,7 +67,7 @@ public class PatternRule implements IPredicateRule {
* Line delimiter comparator which orders according to decreasing delimiter length.
* @since 3.1
*/
- private Comparator fLineDelimiterComparator= new DecreasingCharArrayLengthComparator();
+ private Comparator<char[]> fLineDelimiterComparator= new DecreasingCharArrayLengthComparator();
/**
* Cached line delimiters.
* @since 3.1
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
index e6150e68f0b..2d0303f3607 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/RuleBasedPartitioner.java
@@ -528,7 +528,7 @@ public class RuleBasedPartitioner implements IDocumentPartitioner, IDocumentPart
@Override
public ITypedRegion[] computePartitioning(int offset, int length, boolean includeZeroLengthPartitions) {
- List list= new ArrayList();
+ List<TypedRegion> list= new ArrayList<>();
try {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
index 12ec542a543..d091e18d60b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/WordRule.java
@@ -37,7 +37,7 @@ public class WordRule implements IRule {
/** The column constraint. */
protected int fColumn= UNDEFINED;
/** The table of predefined words and token for this rule. */
- protected Map fWords= new HashMap();
+ protected Map<String, IToken> fWords= new HashMap<>();
/** Buffer used for pattern detection. */
private StringBuffer fBuffer= new StringBuffer();
/**
@@ -143,7 +143,7 @@ public class WordRule implements IRule {
if (fIgnoreCase)
buffer= buffer.toLowerCase();
- IToken token= (IToken)fWords.get(buffer);
+ IToken token= fWords.get(buffer);
if (token != null)
return token;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
index 760b2b6ed7c..3b96efa606a 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationBarHoverManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
@@ -540,7 +540,7 @@ public class AnnotationBarHoverManager extends AbstractHoverInformationControlMa
if (fVerticalRulerInfo instanceof CompositeRuler) {
CompositeRuler comp= (CompositeRuler) fVerticalRulerInfo;
- for (Iterator it= comp.getDecoratorIterator(); it.hasNext();) {
+ for (Iterator<IVerticalRulerColumn> it= comp.getDecoratorIterator(); it.hasNext();) {
Object o= it.next();
if (o instanceof IVerticalRulerInfoExtension && o instanceof IVerticalRulerInfo) {
if (((IVerticalRulerInfo) o).getControl() == event.getSource()) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
index b1361603e23..ef1addf1982 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationPainter.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
@@ -18,8 +18,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.swt.SWT;
@@ -355,12 +355,12 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* The map with decorations
* @since 3.0
*/
- private Map fDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
+ private Map<Annotation, Decoration> fDecorationsMap= new HashMap<>(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
/**
* The map with of highlighted decorations.
* @since 3.0
*/
- private Map fHighlightedDecorationsMap= new HashMap(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
+ private Map<Annotation, Decoration> fHighlightedDecorationsMap= new HashMap<>(); // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=50767
/**
* Mutex for highlighted decorations map.
* @since 3.0
@@ -376,13 +376,13 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
*
* @see #setAnnotationTypeColor(Object, Color)
*/
- private Map fAnnotationType2Color= new HashMap();
+ private Map<Object, Color> fAnnotationType2Color= new HashMap<>();
/**
* Cache that maps the annotation type to its color.
* @since 3.4
*/
- private Map fCachedAnnotationType2Color= new HashMap();
+ private Map<Object, Color> fCachedAnnotationType2Color= new HashMap<>();
/**
* The range in which the current highlight annotations can be found.
* @since 3.0
@@ -421,19 +421,19 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* @see #addAnnotationType(Object, Object)
* @since 3.0
*/
- private Map fAnnotationType2PaintingStrategyId= new HashMap();
+ private Map<Object, Object> fAnnotationType2PaintingStrategyId= new HashMap<>();
/**
* Maps annotation types to painting strategy identifiers.
* @since 3.4
*/
- private Map fCachedAnnotationType2PaintingStrategy= new HashMap();
+ private Map<String, Object> fCachedAnnotationType2PaintingStrategy= new HashMap<>();
/**
* Maps painting strategy identifiers to painting strategies.
*
* @since 3.0
*/
- private Map fPaintingStrategyId2PaintingStrategy= new HashMap();
+ private Map<Object, Object> fPaintingStrategyId2PaintingStrategy= new HashMap<>();
/**
* Reuse this region for performance reasons.
@@ -552,31 +552,31 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
int drawRangeStart= Integer.MAX_VALUE;
int drawRangeEnd= -1;
- Map decorationsMap;
- Map highlightedDecorationsMap;
+ Map<Annotation, Decoration> decorationsMap;
+ Map<Annotation, Decoration> highlightedDecorationsMap;
// Clone decoration maps
synchronized (fDecorationMapLock) {
- decorationsMap= new HashMap(fDecorationsMap);
+ decorationsMap= new HashMap<>(fDecorationsMap);
}
synchronized (fHighlightedDecorationsMapLock) {
- highlightedDecorationsMap= new HashMap(fHighlightedDecorationsMap);
+ highlightedDecorationsMap= new HashMap<>(fHighlightedDecorationsMap);
}
boolean isWorldChange= false;
- Iterator e;
+ Iterator<Annotation> e;
if (event == null || event.isWorldChange()) {
isWorldChange= true;
if (DEBUG && event == null)
System.out.println("AP: INTERNAL CHANGE"); //$NON-NLS-1$
- Iterator iter= decorationsMap.entrySet().iterator();
+ Iterator<Entry<Annotation, Decoration>> iter= decorationsMap.entrySet().iterator();
while (iter.hasNext()) {
- Map.Entry entry= (Map.Entry)iter.next();
- Annotation annotation= (Annotation)entry.getKey();
- Decoration decoration= (Decoration)entry.getValue();
+ Entry<Annotation, Decoration> entry= iter.next();
+ Annotation annotation= entry.getKey();
+ Decoration decoration= entry.getValue();
drawDecoration(decoration, null, annotation, clippingRegion, document);
}
@@ -593,7 +593,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
Annotation[] removedAnnotations= event.getRemovedAnnotations();
for (int i= 0, length= removedAnnotations.length; i < length; i++) {
Annotation annotation= removedAnnotations[i];
- Decoration decoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration decoration= highlightedDecorationsMap.remove(annotation);
if (decoration != null) {
Position position= decoration.fPosition;
if (position != null) {
@@ -601,7 +601,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, position.offset + position.length);
}
}
- decoration= (Decoration)decorationsMap.remove(annotation);
+ decoration= decorationsMap.remove(annotation);
if (decoration != null) {
drawDecoration(decoration, null, annotation, clippingRegion, document);
Position position= decoration.fPosition;
@@ -620,14 +620,14 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
boolean isHighlighting= false;
- Decoration decoration= (Decoration)highlightedDecorationsMap.get(annotation);
+ Decoration decoration= highlightedDecorationsMap.get(annotation);
if (decoration != null) {
isHighlighting= true;
// The call below updates the decoration - no need to create new decoration
decoration= getDecoration(annotation, decoration);
if (decoration == null) {
- Decoration removedDecoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration removedDecoration= highlightedDecorationsMap.remove(annotation);
if (removedDecoration != null) {
highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, removedDecoration.fPosition.offset);
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, removedDecoration.fPosition.offset + removedDecoration.fPosition.length);
@@ -660,7 +660,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
drawRangeEnd= Math.max(drawRangeEnd, position.offset + position.length);
}
} else {
- Decoration removedDecoration= (Decoration)highlightedDecorationsMap.remove(annotation);
+ Decoration removedDecoration= highlightedDecorationsMap.remove(annotation);
if (removedDecoration != null) {
highlightAnnotationRangeStart= Math.min(highlightAnnotationRangeStart, removedDecoration.fPosition.offset);
highlightAnnotationRangeEnd= Math.max(highlightAnnotationRangeEnd, removedDecoration.fPosition.offset + removedDecoration.fPosition.length);
@@ -668,7 +668,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
}
if (usesDrawingStrategy) {
- Decoration oldDecoration= (Decoration)decorationsMap.get(annotation);
+ Decoration oldDecoration= decorationsMap.get(annotation);
if (oldDecoration != null) {
drawDecoration(oldDecoration, null, annotation, clippingRegion, document);
if (decoration != null)
@@ -684,7 +684,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
// Add new annotations
while (e.hasNext()) {
- Annotation annotation= (Annotation)e.next();
+ Annotation annotation= e.next();
Decoration pp= getDecoration(annotation, null);
if (pp != null) {
if (pp.fPaintingStrategy instanceof IDrawingStrategy) {
@@ -910,11 +910,11 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* @since 3.0
*/
private Color getColor(final Object annotationType) {
- Color color= (Color)fCachedAnnotationType2Color.get(annotationType);
+ Color color= fCachedAnnotationType2Color.get(annotationType);
if (color != null)
return color;
- color= (Color)fAnnotationType2Color.get(annotationType);
+ color= fAnnotationType2Color.get(annotationType);
if (color != null) {
fCachedAnnotationType2Color.put(annotationType, color);
return color;
@@ -925,7 +925,7 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
for (int i= 0; i < superTypes.length; i++) {
- color= (Color)fAnnotationType2Color.get(superTypes[i]);
+ color= fAnnotationType2Color.get(superTypes[i]);
if (color != null) {
fCachedAnnotationType2Color.put(annotationType, color);
return color;
@@ -976,13 +976,13 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
@Override
public void applyTextPresentation(TextPresentation tp) {
- Set decorations;
+ Set<Entry<Annotation, Decoration>> decorations;
synchronized (fHighlightedDecorationsMapLock) {
if (fHighlightedDecorationsMap == null || fHighlightedDecorationsMap.isEmpty())
return;
- decorations= new HashSet(fHighlightedDecorationsMap.entrySet());
+ decorations= new HashSet<>(fHighlightedDecorationsMap.entrySet());
}
IRegion region= tp.getExtent();
@@ -992,14 +992,14 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
for (int layer= 0, maxLayer= 1; layer < maxLayer; layer++) {
- for (Iterator iter= decorations.iterator(); iter.hasNext();) {
- Map.Entry entry= (Map.Entry)iter.next();
+ for (Iterator<Entry<Annotation, Decoration>> iter= decorations.iterator(); iter.hasNext();) {
+ Entry<Annotation, Decoration> entry= iter.next();
- Annotation a= (Annotation)entry.getKey();
+ Annotation a= entry.getKey();
if (a.isMarkedDeleted())
continue;
- Decoration pp = (Decoration)entry.getValue();
+ Decoration pp = entry.getValue();
maxLayer= Math.max(maxLayer, pp.fLayer + 1); // dynamically update layer maximum
if (pp.fLayer != layer) // wrong layer: skip annotation
@@ -1362,9 +1362,9 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
final GC gc= event != null ? event.gc : null;
// Clone decorations
- Collection decorations;
+ Collection<Entry<Annotation, Decoration>> decorations;
synchronized (fDecorationMapLock) {
- decorations= new ArrayList(fDecorationsMap.size());
+ decorations= new ArrayList<>(fDecorationsMap.size());
decorations.addAll(fDecorationsMap.entrySet());
}
@@ -1372,27 +1372,27 @@ public class AnnotationPainter implements IPainter, PaintListener, IAnnotationMo
* Create a new list of annotations to be drawn, since removing from decorations is more
* expensive. One bucket per drawing layer. Use linked lists as addition is cheap here.
*/
- ArrayList toBeDrawn= new ArrayList(10);
- for (Iterator e = decorations.iterator(); e.hasNext();) {
- Map.Entry entry= (Map.Entry)e.next();
+ ArrayList<LinkedList<Entry<Annotation, Decoration>>> toBeDrawn= new ArrayList<>(10);
+ for (Iterator<Entry<Annotation, Decoration>> e = decorations.iterator(); e.hasNext();) {
+ Entry<Annotation, Decoration> entry= e.next();
- Annotation a= (Annotation)entry.getKey();
- Decoration pp = (Decoration)entry.getValue();
+ Annotation a= entry.getKey();
+ Decoration pp = entry.getValue();
// prune any annotation that is not drawable or does not need drawing
if (!(a.isMarkedDeleted() || skip(a) || !regionsTouchOrOverlap(pp.fPosition.getOffset(), pp.fPosition.getLength(), vOffset, vLength))) {
// ensure sized appropriately
for (int i= toBeDrawn.size(); i <= pp.fLayer; i++)
- toBeDrawn.add(new LinkedList());
- ((List) toBeDrawn.get(pp.fLayer)).add(entry);
+ toBeDrawn.add(new LinkedList<>());
+ toBeDrawn.get(pp.fLayer).add(entry);
}
}
IDocument document= fSourceViewer.getDocument();
- for (Iterator it= toBeDrawn.iterator(); it.hasNext();) {
- List layer= (List) it.next();
- for (Iterator e = layer.iterator(); e.hasNext();) {
- Map.Entry entry= (Map.Entry)e.next();
- Annotation a= (Annotation)entry.getKey();
- Decoration pp = (Decoration)entry.getValue();
+ for (Iterator<LinkedList<Entry<Annotation, Decoration>>> it= toBeDrawn.iterator(); it.hasNext();) {
+ LinkedList<Entry<Annotation, Decoration>> layer= it.next();
+ for (Iterator<Entry<Annotation, Decoration>> e = layer.iterator(); e.hasNext();) {
+ Entry<Annotation, Decoration> entry= e.next();
+ Annotation a= entry.getKey();
+ Decoration pp = entry.getValue();
drawDecoration(pp, gc, a, clippingRegion, document);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
index 3673751fa0b..0e3472bedc0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationRulerColumn.java
@@ -115,11 +115,11 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* Comparator for <code>Tuple</code>s.
* @since 3.0
*/
- private static class TupleComparator implements Comparator {
+ private static class TupleComparator implements Comparator<Tuple> {
@Override
- public int compare(Object o1, Object o2) {
- Position p1= ((Tuple) o1).position;
- Position p2= ((Tuple) o2).position;
+ public int compare(Tuple o1, Tuple o2) {
+ Position p1= o1.position;
+ Position p2= o2.position;
return p1.getOffset() - p2.getOffset();
}
}
@@ -148,14 +148,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* The list of annotation types to be shown in this ruler.
* @since 3.0
*/
- private Set fConfiguredAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredAnnotationTypes= new HashSet<>();
/**
* The list of allowed annotation types to be shown in this ruler.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedAnnotationTypes= new HashMap<>();
/**
* The annotation access extension.
* @since 3.0
@@ -170,12 +170,12 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
* The cached annotations.
* @since 3.0
*/
- private List fCachedAnnotations= new ArrayList();
+ private List<Tuple> fCachedAnnotations= new ArrayList<>();
/**
* The comparator for sorting annotations according to the offset of their position.
* @since 3.0
*/
- private Comparator fTupleComparator= new TupleComparator();
+ private Comparator<Tuple> fTupleComparator= new TupleComparator();
/**
* The hit detection cursor. Do not dispose.
* @since 3.0
@@ -474,14 +474,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int lineStart= line.getOffset();
int lineLength= line.getLength();
- Iterator e;
+ Iterator<Annotation> e;
if (fModel instanceof IAnnotationModelExtension2)
e= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(lineStart, lineLength + 1, true, true);
else
e= model.getAnnotationIterator();
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (a.isMarkedDeleted())
continue;
@@ -646,14 +646,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int maxLayer= 1; // loop at least once through layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter;
+ Iterator<Annotation> iter;
if (fModel instanceof IAnnotationModelExtension2)
iter= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(topLeft, viewPort + 1, true, true);
else
iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (fAnnotationAccessExtension != null)
@@ -736,14 +736,14 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
int minLayer= Integer.MAX_VALUE, maxLayer= Integer.MIN_VALUE;
fCachedAnnotations.clear();
- Iterator iter;
+ Iterator<Annotation> iter;
if (fModel instanceof IAnnotationModelExtension2)
iter= ((IAnnotationModelExtension2)fModel).getAnnotationIterator(vOffset, vLength + 1, true, true);
else
iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (skip(annotation))
continue;
@@ -769,7 +769,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
for (int layer= minLayer; layer <= maxLayer; layer++) {
for (int i= 0, n= fCachedAnnotations.size(); i < n; i++) {
- Tuple tuple= (Tuple) fCachedAnnotations.get(i);
+ Tuple tuple= fCachedAnnotations.get(i);
Annotation annotation= tuple.annotation;
Position position= tuple.position;
@@ -924,7 +924,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
*/
private boolean skip(Annotation annotation) {
Object annotationType= annotation.getType();
- Boolean allowed= (Boolean) fAllowedAnnotationTypes.get(annotationType);
+ Boolean allowed= fAllowedAnnotationTypes.get(annotationType);
if (allowed != null)
return !allowed.booleanValue();
@@ -944,7 +944,7 @@ public class AnnotationRulerColumn implements IVerticalRulerColumn, IVerticalRul
*/
private boolean skip(Object annotationType) {
if (fAnnotationAccessExtension != null) {
- Iterator e= fConfiguredAnnotationTypes.iterator();
+ Iterator<Object> e= fConfiguredAnnotationTypes.iterator();
while (e.hasNext()) {
if (fAnnotationAccessExtension.isSubtype(annotationType, e.next()))
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
index fca69ff52fb..4b62c5870d1 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/CompositeRuler.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
@@ -102,9 +102,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
int rulerHeight= clArea.height;
int x= 0;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
int columnWidth= column.getWidth();
column.getControl().setBounds(x, 0, columnWidth, rulerHeight);
x += (columnWidth + fGap);
@@ -122,12 +122,12 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* Keeps the information for which event type a listener object has been added.
*/
static class ListenerInfo {
- Class fClass;
+ Class<? extends EventListener> fClass;
EventListener fListener;
}
/** The list of listeners added to this canvas. */
- private List fCachedListeners= new ArrayList();
+ private List<ListenerInfo> fCachedListeners= new ArrayList<>();
/**
* Internal listener for opening the context menu.
* @since 3.0
@@ -173,7 +173,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param control the control to add the listener to
* @param listener the listener to be added
*/
- private void addListener(Class clazz, Control control, EventListener listener) {
+ private void addListener(Class<? extends EventListener> clazz, Control control, EventListener listener) {
if (ControlListener.class.equals(clazz)) {
control. addControlListener((ControlListener) listener);
return;
@@ -228,7 +228,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param control the control to remove the listener from
* @param listener the listener to be removed
*/
- private void removeListener(Class clazz, Control control, EventListener listener) {
+ private void removeListener(Class<? extends EventListener> clazz, Control control, EventListener listener) {
if (ControlListener.class.equals(clazz)) {
control. removeControlListener((ControlListener) listener);
return;
@@ -278,7 +278,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param clazz the listener type
* @param listener the listener object
*/
- private void addListener(Class clazz, EventListener listener) {
+ private void addListener(Class<? extends EventListener> clazz, EventListener listener) {
Control[] children= getChildren();
for (int i= 0; i < children.length; i++) {
if (children[i] != null && !children[i].isDisposed())
@@ -298,7 +298,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param clazz the listener type
* @param listener the listener object
*/
- private void removeListener(Class clazz, EventListener listener) {
+ private void removeListener(Class<? extends EventListener> clazz, EventListener listener) {
// Keep as first statement to ensure checkWidget() is called.
Control[] children= getChildren();
@@ -307,7 +307,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
if (listener == info.fListener && clazz.equals(info.fClass)) {
fCachedListeners.remove(i);
break;
@@ -329,7 +329,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
if (child != null && !child.isDisposed()) {
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
addListener(info.fClass, child, info.fListener);
}
child.addListener(SWT.MenuDetect, fMenuDetectListener);
@@ -345,7 +345,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
if (child != null && !child.isDisposed()) {
int length= fCachedListeners.size();
for (int i= 0; i < length; i++) {
- ListenerInfo info= (ListenerInfo) fCachedListeners.get(i);
+ ListenerInfo info= fCachedListeners.get(i);
removeListener(info.fClass, child, info.fListener);
}
child.removeListener(SWT.MenuDetect, fMenuDetectListener);
@@ -498,7 +498,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
/** The ruler's annotation model */
private IAnnotationModel fModel;
/** The list of columns */
- private List fDecorators= new ArrayList(2);
+ private List<IVerticalRulerColumn> fDecorators= new ArrayList<>(2);
/** The cached location of the last mouse button activity */
private Point fLocation= new Point(-1, -1);
/** The cached line of the list mouse button activity */
@@ -509,7 +509,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* The set of annotation listeners.
* @since 3.0
*/
- private Set fAnnotationListeners= new HashSet();
+ private Set<IVerticalRulerListener> fAnnotationListeners= new HashSet<>();
/**
@@ -556,7 +556,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @param index the index
*/
public void removeDecorator(int index) {
- IVerticalRulerColumn rulerColumn= (IVerticalRulerColumn) fDecorators.get(index);
+ IVerticalRulerColumn rulerColumn= fDecorators.get(index);
removeDecorator(rulerColumn);
}
@@ -608,9 +608,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
fComposite= new CompositeRulerCanvas(parent, SWT.NONE);
fComposite.setLayout(new RulerLayout());
- Iterator iter= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> iter= fDecorators.iterator();
while (iter.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) iter.next();
+ IVerticalRulerColumn column= iter.next();
column.createControl(this, fComposite);
fComposite.childAdded(column.getControl());
}
@@ -623,9 +623,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
fModel= model;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.setModel(model);
}
}
@@ -656,18 +656,18 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @since 3.2
*/
public void immediateUpdate() {
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.redraw();
}
}
@Override
public void setFont(Font font) {
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
column.setFont(font);
}
}
@@ -675,9 +675,9 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
@Override
public int getWidth() {
int width= 0;
- Iterator e= fDecorators.iterator();
+ Iterator<IVerticalRulerColumn> e= fDecorators.iterator();
while (e.hasNext()) {
- IVerticalRulerColumn column= (IVerticalRulerColumn) e.next();
+ IVerticalRulerColumn column= e.next();
width += (column.getWidth() + fGap);
}
return Math.max(0, width - fGap);
@@ -757,7 +757,7 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
* @return an iterator over the contained columns.
* @since 3.0
*/
- public Iterator getDecoratorIterator() {
+ public Iterator<IVerticalRulerColumn> getDecoratorIterator() {
Assert.isNotNull(fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$
return fDecorators.iterator();
}
@@ -787,8 +787,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationSelected(event);
}
}
@@ -803,8 +803,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationDefaultSelected(VerticalRulerEvent event) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationDefaultSelected(event);
}
}
@@ -820,8 +820,8 @@ public class CompositeRuler implements IVerticalRuler, IVerticalRulerExtension,
*/
public void fireAnnotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) {
// forward to listeners
- for (Iterator it= fAnnotationListeners.iterator(); it.hasNext();) {
- IVerticalRulerListener listener= (IVerticalRulerListener) it.next();
+ for (Iterator<IVerticalRulerListener> it= fAnnotationListeners.iterator(); it.hasNext();) {
+ IVerticalRulerListener listener= it.next();
listener.annotationContextMenuAboutToShow(event, menu);
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
index ade74e15b50..9a83dd09149 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 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
@@ -58,31 +58,31 @@ public class DefaultAnnotationHover implements IAnnotationHover {
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- List javaAnnotations= getAnnotationsForLine(sourceViewer, lineNumber);
+ List<Annotation> javaAnnotations= getAnnotationsForLine(sourceViewer, lineNumber);
if (javaAnnotations != null) {
if (javaAnnotations.size() == 1) {
// optimization
- Annotation annotation= (Annotation) javaAnnotations.get(0);
+ Annotation annotation= javaAnnotations.get(0);
String message= annotation.getText();
if (message != null && message.trim().length() > 0)
return formatSingleMessage(message);
} else {
- List messages= new ArrayList();
+ List<String> messages= new ArrayList<>();
- Iterator e= javaAnnotations.iterator();
+ Iterator<Annotation> e= javaAnnotations.iterator();
while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
+ Annotation annotation= e.next();
String message= annotation.getText();
if (message != null && message.trim().length() > 0)
messages.add(message.trim());
}
if (messages.size() == 1)
- return formatSingleMessage((String)messages.get(0));
+ return formatSingleMessage(messages.get(0));
if (messages.size() > 1)
return formatMultipleMessages(messages);
@@ -127,17 +127,17 @@ public class DefaultAnnotationHover implements IAnnotationHover {
* format like HTML.
* </p>
*
- * @param messages the messages to format (element type: {@link String})
+ * @param messages the messages to format
* @return the formatted message
*/
- protected String formatMultipleMessages(List messages) {
+ protected String formatMultipleMessages(List<String> messages) {
StringBuffer buffer= new StringBuffer();
buffer.append(JFaceTextMessages.getString("DefaultAnnotationHover.multipleMarkers")); //$NON-NLS-1$
- Iterator e= messages.iterator();
+ Iterator<String> e= messages.iterator();
while (e.hasNext()) {
buffer.append('\n');
- String listItemText= (String) e.next();
+ String listItemText= e.next();
buffer.append(JFaceTextMessages.getFormattedString("DefaultAnnotationHover.listItem", new String[] { listItemText })); //$NON-NLS-1$
}
return buffer.toString();
@@ -161,20 +161,21 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return viewer.getAnnotationModel();
}
- private boolean isDuplicateAnnotation(Map messagesAtPosition, Position position, String message) {
+ private boolean isDuplicateAnnotation(Map<Position, Object> messagesAtPosition, Position position, String message) {
if (messagesAtPosition.containsKey(position)) {
Object value= messagesAtPosition.get(position);
if (message.equals(value))
return true;
if (value instanceof List) {
- List messages= (List)value;
+ @SuppressWarnings("unchecked")
+ List<Object> messages= (List<Object>) value;
if (messages.contains(message))
return true;
messages.add(message);
} else {
- ArrayList messages= new ArrayList();
+ ArrayList<Object> messages= new ArrayList<>();
messages.add(value);
messages.add(message);
messagesAtPosition.put(position, messages);
@@ -184,7 +185,7 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return false;
}
- private boolean includeAnnotation(Annotation annotation, Position position, HashMap messagesAtPosition) {
+ private boolean includeAnnotation(Annotation annotation, Position position, HashMap<Position, Object> messagesAtPosition) {
if (!isIncluded(annotation))
return false;
@@ -192,18 +193,18 @@ public class DefaultAnnotationHover implements IAnnotationHover {
return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}
- private List getAnnotationsForLine(ISourceViewer viewer, int line) {
+ private List<Annotation> getAnnotationsForLine(ISourceViewer viewer, int line) {
IAnnotationModel model= getAnnotationModel(viewer);
if (model == null)
return null;
IDocument document= viewer.getDocument();
- List javaAnnotations= new ArrayList();
- HashMap messagesAtPosition= new HashMap();
- Iterator iterator= model.getAnnotationIterator();
+ List<Annotation> javaAnnotations= new ArrayList<>();
+ HashMap<Position, Object> messagesAtPosition= new HashMap<>();
+ Iterator<Annotation> iterator= model.getAnnotationIterator();
while (iterator.hasNext()) {
- Annotation annotation= (Annotation) iterator.next();
+ Annotation annotation= iterator.next();
Position position= model.getPosition(annotation);
if (position == null)
@@ -214,9 +215,9 @@ public class DefaultAnnotationHover implements IAnnotationHover {
if (annotation instanceof AnnotationBag) {
AnnotationBag bag= (AnnotationBag) annotation;
- Iterator e= bag.iterator();
+ Iterator<Annotation> e= bag.iterator();
while (e.hasNext()) {
- annotation= (Annotation) e.next();
+ annotation= e.next();
position= model.getPosition(annotation);
if (position != null && includeAnnotation(annotation, position, messagesAtPosition))
javaAnnotations.add(annotation);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
index 4b9df872431..73522d8190d 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineChangeHover.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
@@ -88,7 +88,7 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens
if (differ == null)
return null;
- final List lines= new LinkedList();
+ final List<ILineDiffInfo> lines= new LinkedList<>();
for (int l= first; l <= last; l++) {
ILineDiffInfo info= differ.getLineInfo(l);
if (info != null)
@@ -110,15 +110,15 @@ public class LineChangeHover implements IAnnotationHover, IAnnotationHoverExtens
* more than that due to deleted lines.
* @return a <code>String</code> suitable for hover display
*/
- protected String decorateText(List diffInfos, int maxLines) {
+ protected String decorateText(List<? extends ILineDiffInfo> diffInfos, int maxLines) {
/* maxLines controls the size of the hover (not more than what fits into the display are of
* the viewer).
* added controls how many lines are added - added lines are
*/
String text= ""; //$NON-NLS-1$
int added= 0;
- for (Iterator it= diffInfos.iterator(); it.hasNext();) {
- ILineDiffInfo info= (ILineDiffInfo)it.next();
+ for (Iterator<? extends ILineDiffInfo> it= diffInfos.iterator(); it.hasNext();) {
+ ILineDiffInfo info= it.next();
String[] original= info.getOriginalText();
int type= info.getChangeType();
int i= 0;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
index 153fc777685..7f060da4b5f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/OverviewRuler.java
@@ -137,13 +137,13 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* Enumerates the annotations of a specified type and characteristics
* of the associated annotation model.
*/
- class FilterIterator implements Iterator {
+ class FilterIterator implements Iterator<Annotation> {
final static int TEMPORARY= 1 << 1;
final static int PERSISTENT= 1 << 2;
final static int IGNORE_BAGS= 1 << 3;
- private Iterator fIterator;
+ private Iterator<Annotation> fIterator;
private Object fType;
private Annotation fNext;
private int fStyle;
@@ -170,7 +170,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* @param style the style
* @param iterator the iterator
*/
- public FilterIterator(Object annotationType, int style, Iterator iterator) {
+ public FilterIterator(Object annotationType, int style, Iterator<Annotation> iterator) {
fType= annotationType;
fStyle= style;
fIterator= iterator;
@@ -184,7 +184,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
boolean ignr= (fStyle & IGNORE_BAGS) != 0;
while (fIterator.hasNext()) {
- Annotation next= (Annotation) fIterator.next();
+ Annotation next= fIterator.next();
if (next.isMarkedDeleted())
continue;
@@ -216,7 +216,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
return fNext != null;
}
@Override
- public Object next() {
+ public Annotation next() {
try {
return fNext;
} finally {
@@ -403,14 +403,14 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* The list of annotation types to be shown in this ruler.
* @since 3.0
*/
- private Set fConfiguredAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredAnnotationTypes= new HashSet<>();
/**
* The list of annotation types to be shown in the header of this ruler.
* @since 3.0
*/
- private Set fConfiguredHeaderAnnotationTypes= new HashSet();
+ private Set<Object> fConfiguredHeaderAnnotationTypes= new HashSet<>();
/** The mapping between annotation types and colors */
- private Map fAnnotationTypes2Colors= new HashMap();
+ private Map<Object, Color> fAnnotationTypes2Colors= new HashMap<>();
/** The color manager */
private ISharedTextColors fSharedTextColors;
/**
@@ -418,32 +418,32 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
*
* @since 3.0
*/
- private List fAnnotationsSortedByLayer= new ArrayList();
+ private List<Object> fAnnotationsSortedByLayer= new ArrayList<>();
/**
* All available layers sorted by layer.
* This list may contain duplicates.
* @since 3.0
*/
- private List fLayersSortedByLayer= new ArrayList();
+ private List<Integer> fLayersSortedByLayer= new ArrayList<>();
/**
* Map of allowed annotation types.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedAnnotationTypes= new HashMap<>();
/**
* Map of allowed header annotation types.
* An allowed annotation type maps to <code>true</code>, a disallowed
* to <code>false</code>.
* @since 3.0
*/
- private Map fAllowedHeaderAnnotationTypes= new HashMap();
+ private Map<Object, Boolean> fAllowedHeaderAnnotationTypes= new HashMap<>();
/**
* The cached annotations.
* @since 3.0
*/
- private List fCachedAnnotations= new ArrayList();
+ private List<Annotation> fCachedAnnotations= new ArrayList<>();
/**
* Redraw runnable lock
@@ -695,9 +695,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
private void cacheAnnotations() {
fCachedAnnotations.clear();
if (fModel != null) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
if (annotation.isMarkedDeleted())
continue;
@@ -731,7 +731,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
WidgetInfos infos= null;
- for (Iterator iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
+ for (Iterator<Object> iterator= fAnnotationsSortedByLayer.iterator(); iterator.hasNext();) {
Object annotationType= iterator.next();
if (skip(annotationType))
@@ -743,9 +743,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Color fill= null;
Color stroke= null;
- Iterator e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, style[t], fCachedAnnotations.iterator());
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
Position p= fModel.getPosition(a);
if (p == null)
@@ -1036,9 +1036,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Object annotationType= fAnnotationsSortedByLayer.get(i);
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY);
while (e.hasNext() && found == null) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
if (a.isMarkedDeleted())
continue;
@@ -1179,7 +1179,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
if (layer >= 0) {
int i= 0;
int size= fLayersSortedByLayer.size();
- while (i < size && layer >= ((Integer)fLayersSortedByLayer.get(i)).intValue())
+ while (i < size && layer >= fLayersSortedByLayer.get(i).intValue())
i++;
Integer layerObj= new Integer(layer);
fLayersSortedByLayer.add(i, layerObj);
@@ -1228,10 +1228,10 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* otherwise
* @since 3.0
*/
- private boolean contains(Object annotationType, Map allowed, Set configured) {
+ private boolean contains(Object annotationType, Map<Object, Boolean> allowed, Set<Object> configured) {
boolean covered;
synchronized (fRunnableLock){
- Boolean cached= (Boolean) allowed.get(annotationType);
+ Boolean cached= allowed.get(annotationType);
if (cached != null)
return cached.booleanValue();
@@ -1252,10 +1252,10 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* otherwise
* @since 3.0
*/
- private boolean isCovered(Object annotationType, Set configured) {
+ private boolean isCovered(Object annotationType, Set<Object> configured) {
if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- Iterator e= configured.iterator();
+ Iterator<Object> e= configured.iterator();
while (e.hasNext()) {
if (extension.isSubtype(annotationType,e.next()))
return true;
@@ -1337,7 +1337,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
* @since 3.0
*/
private Color findColor(Object annotationType) {
- Color color= (Color) fAnnotationTypes2Colors.get(annotationType);
+ Color color= fAnnotationTypes2Colors.get(annotationType);
if (color != null)
return color;
@@ -1346,7 +1346,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
Object[] superTypes= extension.getSupertypes(annotationType);
if (superTypes != null) {
for (int i= 0; i < superTypes.length; i++) {
- color= (Color) fAnnotationTypes2Colors.get(superTypes[i]);
+ color= fAnnotationTypes2Colors.get(superTypes[i]);
if (color != null)
return color;
}
@@ -1451,7 +1451,7 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
if (skipInHeader(annotationType) || skip(annotationType))
continue;
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
while (e.hasNext()) {
if (e.next() != null) {
colorType= annotationType;
@@ -1501,9 +1501,9 @@ public class OverviewRuler implements IOverviewRulerExtension, IOverviewRuler {
int count= 0;
String annotationTypeLabel= null;
- Iterator e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
+ Iterator<Annotation> e= new FilterIterator(annotationType, FilterIterator.PERSISTENT | FilterIterator.TEMPORARY | FilterIterator.IGNORE_BAGS, fCachedAnnotations.iterator());
while (e.hasNext()) {
- Annotation annotation= (Annotation)e.next();
+ Annotation annotation= e.next();
if (annotation != null) {
if (annotationTypeLabel == null)
annotationTypeLabel= ((IAnnotationAccessExtension)fAnnotationAccess).getTypeLabel(annotation);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
index 29ed1c65b3c..f8448a7c318 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/SourceViewer.java
@@ -295,7 +295,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
* Stack of saved selections in the underlying document
* @since 3.0
*/
- protected final Stack fSelections= new Stack();
+ protected final Stack<Position> fSelections= new Stack<>();
/**
* Position updater for saved selections
* @since 3.0
@@ -877,7 +877,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
if (!fSelections.isEmpty()) {
final IDocument document= getDocument();
- final Position position= (Position) fSelections.pop();
+ final Position position= fSelections.pop();
try {
document.removePosition(fSelectionCategory, position);
@@ -1148,7 +1148,7 @@ public class SourceViewer extends TextViewer implements ISourceViewer, ISourceVi
return true;
if (fVerticalRuler instanceof CompositeRuler) {
- Iterator iter= ((CompositeRuler)fVerticalRuler).getDecoratorIterator();
+ Iterator<IVerticalRulerColumn> iter= ((CompositeRuler)fVerticalRuler).getDecoratorIterator();
return iter.hasNext() && iter.next() instanceof AnnotationRulerColumn && !iter.hasNext();
}
return false;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
index 005c8c21a90..b710fafa605 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/VerticalRuler.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
@@ -307,10 +307,10 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
int maxLayer= 1; // loop at least once though layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
IAnnotationPresentation annotationPresentation= null;
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (annotationAccessExtension != null)
@@ -394,10 +394,10 @@ public final class VerticalRuler implements IVerticalRuler, IVerticalRulerExtens
int maxLayer= 1; // loop at least once through layers.
for (int layer= 0; layer < maxLayer; layer++) {
- Iterator iter= fModel.getAnnotationIterator();
+ Iterator<Annotation> iter= fModel.getAnnotationIterator();
while (iter.hasNext()) {
IAnnotationPresentation annotationPresentation= null;
- Annotation annotation= (Annotation) iter.next();
+ Annotation annotation= iter.next();
int lay= IAnnotationAccessExtension.DEFAULT_LAYER;
if (annotationAccessExtension != null)
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
index 8a216202538..cb8b9f68ea0 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/ContextTypeRegistry.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
@@ -27,7 +27,7 @@ import java.util.Map;
public class ContextTypeRegistry {
/** all known context types */
- private final Map fContextTypes= new LinkedHashMap();
+ private final Map<String, TemplateContextType> fContextTypes= new LinkedHashMap<>();
/**
* Adds a context type to the registry. If there already is a context type
@@ -46,15 +46,15 @@ public class ContextTypeRegistry {
* @return the context type if <code>name</code> is valid, <code>null</code> otherwise
*/
public TemplateContextType getContextType(String id) {
- return (TemplateContextType) fContextTypes.get(id);
+ return fContextTypes.get(id);
}
/**
* Returns an iterator over all registered context types.
*
- * @return an iterator over all registered context types (element type: {@link TemplateContextType})
+ * @return an iterator over all registered context types
*/
- public Iterator contextTypes() {
+ public Iterator<TemplateContextType> contextTypes() {
return fContextTypes.values().iterator();
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
index f3d6e7ae19e..4fd70687c97 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/TemplateCompletionProcessor.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
@@ -38,14 +38,16 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator;
*/
public abstract class TemplateCompletionProcessor implements IContentAssistProcessor {
- private static final class ProposalComparator implements Comparator {
+ private static final class ProposalComparator implements Comparator<ICompletionProposal> {
@Override
- public int compare(Object o1, Object o2) {
- return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance();
+ public int compare(ICompletionProposal o1, ICompletionProposal o2) {
+ int r1= o1 instanceof TemplateProposal ? ((TemplateProposal) o1).getRelevance() : 0;
+ int r2= o2 instanceof TemplateProposal ? ((TemplateProposal) o2).getRelevance() : 0;
+ return r2 - r1;
}
}
- private static final Comparator fgProposalComparator= new ProposalComparator();
+ private static final Comparator<ICompletionProposal> fgProposalComparator= new ProposalComparator();
@Override
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
@@ -66,7 +68,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce
Template[] templates= getTemplates(context.getContextType().getId());
- List matches= new ArrayList();
+ List<ICompletionProposal> matches= new ArrayList<>();
for (int i= 0; i < templates.length; i++) {
Template template= templates[i];
try {
@@ -80,7 +82,7 @@ public abstract class TemplateCompletionProcessor implements IContentAssistProce
Collections.sort(matches, fgProposalComparator);
- return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]);
+ return matches.toArray(new ICompletionProposal[matches.size()]);
}
/**
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
index 4a0aa208ad3..cda02f46a36 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateReaderWriter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 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
@@ -145,8 +145,8 @@ public class TemplateReaderWriter {
*/
private TemplatePersistenceData[] read(InputSource source, ResourceBundle bundle, String singleId) throws IOException {
try {
- Collection templates= new ArrayList();
- Set ids= new HashSet();
+ Collection<TemplatePersistenceData> templates= new ArrayList<>();
+ Set<String> ids= new HashSet<>();
DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
DocumentBuilder parser= factory.newDocumentBuilder();
@@ -206,7 +206,7 @@ public class TemplateReaderWriter {
break;
}
- return (TemplatePersistenceData[]) templates.toArray(new TemplatePersistenceData[templates.size()]);
+ return templates.toArray(new TemplatePersistenceData[templates.size()]);
} catch (ParserConfigurationException e) {
Assert.isTrue(false);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
index edbdbcab920..631955a5bdd 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
@@ -38,7 +38,7 @@ import org.eclipse.jface.text.templates.TemplateException;
*/
public class TemplateStore {
/** The stored templates. */
- private final List fTemplates= new ArrayList();
+ private final List<TemplatePersistenceData> fTemplates= new ArrayList<>();
/** The preference store. */
private IPreferenceStore fPreferenceStore;
/**
@@ -185,8 +185,8 @@ public class TemplateStore {
if (!data.isCustom()) {
// check if the added template is not a duplicate id
String id= data.getId();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData d2= it.next();
if (d2.getId() != null && d2.getId().equals(id))
return;
}
@@ -200,16 +200,16 @@ public class TemplateStore {
* @throws IOException if the templates cannot be written
*/
public void save() throws IOException {
- ArrayList custom= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ ArrayList<TemplatePersistenceData> custom= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isCustom() && !(data.isUserAdded() && data.isDeleted())) // don't save deleted user-added templates
custom.add(data);
}
StringWriter output= new StringWriter();
TemplateReaderWriter writer= new TemplateReaderWriter();
- writer.save((TemplatePersistenceData[]) custom.toArray(new TemplatePersistenceData[custom.size()]), output);
+ writer.save(custom.toArray(new TemplatePersistenceData[custom.size()]), output);
fIgnorePreferenceStoreChanges= true;
try {
@@ -234,8 +234,8 @@ public class TemplateStore {
if (data.isUserAdded()) {
fTemplates.add(data);
} else {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData d2= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData d2= it.next();
if (d2.getId() != null && d2.getId().equals(data.getId())) {
d2.setTemplate(data.getTemplate());
d2.setDeleted(data.isDeleted());
@@ -268,8 +268,8 @@ public class TemplateStore {
* Restores all contributed templates that have been deleted.
*/
public void restoreDeleted() {
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isDeleted())
data.setDeleted(false);
}
@@ -336,14 +336,14 @@ public class TemplateStore {
* @return all enabled templates for the given context type
*/
public Template[] getTemplates(String contextTypeId) {
- List templates= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ List<Template> templates= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (data.isEnabled() && !data.isDeleted() && (contextTypeId == null || contextTypeId.equals(data.getTemplate().getContextTypeId())))
templates.add(data.getTemplate());
}
- return (Template[]) templates.toArray(new Template[templates.size()]);
+ return templates.toArray(new Template[templates.size()]);
}
/**
@@ -366,8 +366,8 @@ public class TemplateStore {
public Template findTemplate(String name, String contextTypeId) {
Assert.isNotNull(name);
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
Template template= data.getTemplate();
if (data.isEnabled() && !data.isDeleted()
&& (contextTypeId == null || contextTypeId.equals(template.getContextTypeId()))
@@ -400,14 +400,14 @@ public class TemplateStore {
* @return all template data, whether enabled or not
*/
public TemplatePersistenceData[] getTemplateData(boolean includeDeleted) {
- List datas= new ArrayList();
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ List<TemplatePersistenceData> datas= new ArrayList<>();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (includeDeleted || !data.isDeleted())
datas.add(data);
}
- return (TemplatePersistenceData[]) datas.toArray(new TemplatePersistenceData[datas.size()]);
+ return datas.toArray(new TemplatePersistenceData[datas.size()]);
}
/**
@@ -420,8 +420,8 @@ public class TemplateStore {
*/
public TemplatePersistenceData getTemplateData(String id) {
Assert.isNotNull(id);
- for (Iterator it= fTemplates.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
+ for (Iterator<TemplatePersistenceData> it= fTemplates.iterator(); it.hasNext();) {
+ TemplatePersistenceData data= it.next();
if (id.equals(data.getId()))
return data;
}

Back to the top