[autocomplete] 134/143: Getting code to build with JDK5 with no warnings.
Benjamin Mesing
ben at alioth.debian.org
Sat Oct 19 12:53:32 UTC 2013
This is an automated email from the git hooks/post-receive script.
ben pushed a commit to branch master
in repository autocomplete.
commit 99059bf66268bfcc126c0337a6ee0e7a08a08ed3
Author: bobbylight <robert at fifesoft.com>
Date: Fri Aug 9 16:56:49 2013 -0400
Getting code to build with JDK5 with no warnings.
---
.../fife/ui/autocomplete/AbstractCompletion.java | 7 +--
.../autocomplete/AbstractCompletionProvider.java | 20 ++++---
.../ui/autocomplete/AutoCompleteDescWindow.java | 17 +++---
.../ui/autocomplete/AutoCompletePopupWindow.java | 2 +-
src/org/fife/ui/autocomplete/AutoCompletion.java | 5 +-
src/org/fife/ui/autocomplete/Completion.java | 6 +-
.../ui/autocomplete/CompletionCellRenderer.java | 2 +-
.../fife/ui/autocomplete/CompletionListModel.java | 8 ++-
.../fife/ui/autocomplete/CompletionProvider.java | 6 +-
.../ui/autocomplete/CompletionProviderBase.java | 8 +--
.../fife/ui/autocomplete/CompletionXMLParser.java | 21 ++++---
.../ui/autocomplete/DefaultCompletionProvider.java | 21 +++----
.../fife/ui/autocomplete/FunctionCompletion.java | 9 ++-
.../LanguageAwareCompletionProvider.java | 20 ++++---
.../fife/ui/autocomplete/MarkupTagCompletion.java | 10 ++--
.../ui/autocomplete/ParameterChoicesProvider.java | 2 +-
.../ParameterizedCompletionChoicesWindow.java | 18 +++---
.../ParameterizedCompletionContext.java | 61 +++++++++-----------
.../ParameterizedCompletionInsertionInfo.java | 12 ++--
.../ui/autocomplete/SortByRelevanceComparator.java | 6 +-
.../fife/ui/autocomplete/TemplateCompletion.java | 14 ++---
src/org/fife/ui/autocomplete/Util.java | 11 ++--
22 files changed, 140 insertions(+), 146 deletions(-)
diff --git a/src/org/fife/ui/autocomplete/AbstractCompletion.java b/src/org/fife/ui/autocomplete/AbstractCompletion.java
index 3a19e2f..666f4bf 100644
--- a/src/org/fife/ui/autocomplete/AbstractCompletion.java
+++ b/src/org/fife/ui/autocomplete/AbstractCompletion.java
@@ -57,12 +57,11 @@ public abstract class AbstractCompletion implements Completion {
/**
* {@inheritDoc}
*/
- public int compareTo(Object o) {
- if (o==this) {
+ public int compareTo(Completion c2) {
+ if (c2==this) {
return 0;
}
- else if (o instanceof Completion) {
- Completion c2 = (Completion)o;
+ else if (c2!=null) {
return toString().compareToIgnoreCase(c2.toString());
}
return -1;
diff --git a/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java b/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
index bfd2a06..d6c4339 100644
--- a/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
+++ b/src/org/fife/ui/autocomplete/AbstractCompletionProvider.java
@@ -32,12 +32,12 @@ public abstract class AbstractCompletionProvider
* The completions this provider is aware of. Subclasses should ensure
* that this list is sorted alphabetically (case-insensitively).
*/
- protected List completions;
+ protected List<Completion> completions;
/**
* Compares a {@link Completion} against a String.
*/
- protected Comparator comparator;
+ protected CaseInsensitiveComparator comparator;
/**
@@ -78,10 +78,9 @@ public abstract class AbstractCompletionProvider
* @see #removeCompletion(Completion)
* @see #clear()
*/
- public void addCompletions(List completions) {
+ public void addCompletions(List<Completion> completions) {
//this.completions.addAll(completions);
- for (int i=0; i<completions.size(); i++) {
- Completion c = (Completion)completions.get(i);
+ for (Completion c : completions) {
checkProviderAndAdd(c);
}
Collections.sort(this.completions);
@@ -132,7 +131,8 @@ public abstract class AbstractCompletionProvider
* @return A list of {@link Completion}s, or <code>null</code> if there
* are no matching <tt>Completion</tt>s.
*/
- public List getCompletionByInputText(String inputText) {
+ @SuppressWarnings("unchecked")
+ public List<Completion> getCompletionByInputText(String inputText) {
// Find any entry that matches this input text (there may be > 1).
int end = Collections.binarySearch(completions, inputText, comparator);
@@ -158,9 +158,10 @@ public abstract class AbstractCompletionProvider
/**
* {@inheritDoc}
*/
- protected List getCompletionsImpl(JTextComponent comp) {
+ @SuppressWarnings("unchecked")
+ protected List<Completion> getCompletionsImpl(JTextComponent comp) {
- List retVal = new ArrayList();
+ List<Completion> retVal = new ArrayList<Completion>();
String text = getAlreadyEnteredText(comp);
if (text!=null) {
@@ -183,7 +184,7 @@ public abstract class AbstractCompletionProvider
}
while (index<completions.size()) {
- Completion c = (Completion)completions.get(index);
+ Completion c = completions.get(index);
if (Util.startsWithIgnoreCase(c.getInputText(), text)) {
retVal.add(c);
index++;
@@ -226,6 +227,7 @@ public abstract class AbstractCompletionProvider
* A comparator that compares the input text of a {@link Completion}
* against a String lexicographically, ignoring case.
*/
+ @SuppressWarnings("rawtypes")
private static class CaseInsensitiveComparator implements Comparator,
Serializable {
diff --git a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
index d141dce..dbe9808 100644
--- a/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompleteDescWindow.java
@@ -92,7 +92,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
/**
* History of descriptions displayed.
*/
- private List history;
+ private List<HistoryEntry> history;
/**
* The current position in {@link #history}.
@@ -194,7 +194,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
}
}
- history = new ArrayList(1); // Usually small
+ history = new ArrayList<HistoryEntry>(1); // Usually small
historyPos = -1;
timerAction = new TimerAction();
@@ -298,8 +298,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
// Custom hyperlink handler for this completion type
ExternalURLHandler handler = ac.getExternalURLHandler();
if (handler!=null) {
- HistoryEntry current = (HistoryEntry)history.
- get(historyPos);
+ HistoryEntry current = history.get(historyPos);
handler.urlClicked(e, current.completion, this);
return;
}
@@ -322,11 +321,11 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
CompletionProvider p = parent.getSelection().getProvider();
if (p instanceof AbstractCompletionProvider) {
String name = e.getDescription();
- List l = ((AbstractCompletionProvider)p).
+ List<Completion> l = ((AbstractCompletionProvider)p).
getCompletionByInputText(name);
if (l!=null && !l.isEmpty()) {
// Just use the 1st one if there's more than 1
- Completion c = (Completion)l.get(0);
+ Completion c = l.get(0);
setDescriptionFor(c, true);
}
else {
@@ -538,8 +537,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
public void actionPerformed(ActionEvent e) {
if (historyPos>0) {
- HistoryEntry pair = (HistoryEntry)history.
- get(--historyPos);
+ HistoryEntry pair = history.get(--historyPos);
descArea.setText(pair.summary);
if (pair.anchor!=null) {
//System.out.println("Scrolling to: " + pair.anchor);
@@ -570,8 +568,7 @@ class AutoCompleteDescWindow extends JWindow implements HyperlinkListener,
public void actionPerformed(ActionEvent e) {
if (history!=null && historyPos<history.size()-1) {
- HistoryEntry pair = (HistoryEntry)history.
- get(++historyPos);
+ HistoryEntry pair = history.get(++historyPos);
descArea.setText(pair.summary);
if (pair.anchor!=null) {
//System.out.println("Scrolling to: " + pair.anchor);
diff --git a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
index 0956704..bd89f87 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletePopupWindow.java
@@ -571,7 +571,7 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener,
*
* @param completions The completions to display.
*/
- public void setCompletions(List completions) {
+ public void setCompletions(List<Completion> completions) {
model.setContents(completions);
selectFirstItem();
}
diff --git a/src/org/fife/ui/autocomplete/AutoCompletion.java b/src/org/fife/ui/autocomplete/AutoCompletion.java
index 8f9b25e..a7f6612 100644
--- a/src/org/fife/ui/autocomplete/AutoCompletion.java
+++ b/src/org/fife/ui/autocomplete/AutoCompletion.java
@@ -699,7 +699,8 @@ public class AutoCompletion {
}
}
- final List completions = provider.getCompletions(textComponent);
+ final List<Completion> completions = provider.
+ getCompletions(textComponent);
int count = completions.size();
if (count>1 || (count==1 && (isPopupVisible() || textLen==0)) ||
@@ -748,7 +749,7 @@ public class AutoCompletion {
else if (count==1) { // !isPopupVisible && autoCompleteSingleChoices
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- insertCompletion((Completion)completions.get(0));
+ insertCompletion(completions.get(0));
}
});
}
diff --git a/src/org/fife/ui/autocomplete/Completion.java b/src/org/fife/ui/autocomplete/Completion.java
index dc65995..2eb9b01 100644
--- a/src/org/fife/ui/autocomplete/Completion.java
+++ b/src/org/fife/ui/autocomplete/Completion.java
@@ -36,17 +36,17 @@ import javax.swing.text.JTextComponent;
* @version 1.0
* @see AbstractCompletion
*/
-public interface Completion extends Comparable {
+public interface Completion extends Comparable<Completion> {
/**
* Compares this completion to another one lexicographically, ignoring
* case.
*
- * @param o Another completion instance.
+ * @param other Another completion instance.
* @return How this completion compares to the other one.
*/
- public int compareTo(Object o);
+ public int compareTo(Completion other);
/**
diff --git a/src/org/fife/ui/autocomplete/CompletionCellRenderer.java b/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
index 2177f16..4546fcd 100644
--- a/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
+++ b/src/org/fife/ui/autocomplete/CompletionCellRenderer.java
@@ -156,7 +156,7 @@ public class CompletionCellRenderer extends DefaultListCellRenderer {
* @see #setDelegateRenderer(DefaultListCellRenderer)
*/
public void delegateToSubstanceRenderer() throws Exception {
- Class clazz = Class.forName(SUBSTANCE_RENDERER_CLASS_NAME);
+ Class<?> clazz = Class.forName(SUBSTANCE_RENDERER_CLASS_NAME);
DefaultListCellRenderer delegate =
(DefaultListCellRenderer)clazz.newInstance();
setDelegateRenderer(delegate);
diff --git a/src/org/fife/ui/autocomplete/CompletionListModel.java b/src/org/fife/ui/autocomplete/CompletionListModel.java
index d9433c0..b256f17 100644
--- a/src/org/fife/ui/autocomplete/CompletionListModel.java
+++ b/src/org/fife/ui/autocomplete/CompletionListModel.java
@@ -10,6 +10,8 @@ package org.fife.ui.autocomplete;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
+
import javax.swing.AbstractListModel;
@@ -26,14 +28,14 @@ class CompletionListModel extends AbstractListModel {
/**
* Container for items in this model.
*/
- private ArrayList delegate;
+ private List<Completion> delegate;
/**
* Constructor.
*/
public CompletionListModel() {
- delegate = new ArrayList();
+ delegate = new ArrayList<Completion>();
}
@@ -73,7 +75,7 @@ class CompletionListModel extends AbstractListModel {
*
* @param contents The new contents of this model.
*/
- public void setContents(Collection contents) {
+ public void setContents(Collection<Completion> contents) {
clear();
if (contents.size()>0) {
delegate.addAll(contents);
diff --git a/src/org/fife/ui/autocomplete/CompletionProvider.java b/src/org/fife/ui/autocomplete/CompletionProvider.java
index f880f30..acd8420 100644
--- a/src/org/fife/ui/autocomplete/CompletionProvider.java
+++ b/src/org/fife/ui/autocomplete/CompletionProvider.java
@@ -60,7 +60,7 @@ public interface CompletionProvider {
* @return The list of {@link Completion}s. If no completions are
* available, this may be <code>null</code>.
*/
- public List getCompletions(JTextComponent comp);
+ public List<Completion> getCompletions(JTextComponent comp);
/**
@@ -72,7 +72,7 @@ public interface CompletionProvider {
* @param p The position, usually from a <tt>MouseEvent</tt>.
* @return The completions, or an empty list if there are none.
*/
- public List getCompletionsAt(JTextComponent comp, Point p);
+ public List<Completion> getCompletionsAt(JTextComponent comp, Point p);
/**
@@ -106,7 +106,7 @@ public interface CompletionProvider {
* @return The list of {@link ParameterizedCompletion}s. If no completions
* are available, this may be <code>null</code>.
*/
- public List getParameterizedCompletions(JTextComponent tc);
+ public List<ParameterizedCompletion> getParameterizedCompletions(JTextComponent tc);
/**
diff --git a/src/org/fife/ui/autocomplete/CompletionProviderBase.java b/src/org/fife/ui/autocomplete/CompletionProviderBase.java
index 9288a08..8abb2cd 100644
--- a/src/org/fife/ui/autocomplete/CompletionProviderBase.java
+++ b/src/org/fife/ui/autocomplete/CompletionProviderBase.java
@@ -81,7 +81,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
* Comparator used to sort completions by their relevance before sorting
* them lexicographically.
*/
- private static final Comparator sortByRelevanceComparator =
+ private static final Comparator<Completion> sortByRelevanceComparator =
new SortByRelevanceComparator();
@@ -97,9 +97,9 @@ public abstract class CompletionProviderBase implements CompletionProvider {
/**
* {@inheritDoc}
*/
- public List getCompletions(JTextComponent comp) {
+ public List<Completion> getCompletions(JTextComponent comp) {
- List completions = getCompletionsImpl(comp);
+ List<Completion> completions = getCompletionsImpl(comp);
if (parent!=null) {
completions.addAll(parent.getCompletions(comp));
Collections.sort(completions);
@@ -124,7 +124,7 @@ public abstract class CompletionProviderBase implements CompletionProvider {
* @return The list of possible completions, or an empty list if there
* are none.
*/
- protected abstract List getCompletionsImpl(JTextComponent comp);
+ protected abstract List<Completion> getCompletionsImpl(JTextComponent comp);
/**
diff --git a/src/org/fife/ui/autocomplete/CompletionXMLParser.java b/src/org/fife/ui/autocomplete/CompletionXMLParser.java
index a1003a4..59e135d 100644
--- a/src/org/fife/ui/autocomplete/CompletionXMLParser.java
+++ b/src/org/fife/ui/autocomplete/CompletionXMLParser.java
@@ -32,7 +32,7 @@ public class CompletionXMLParser extends DefaultHandler {
/**
* The completions found after parsing the XML.
*/
- private List completions;
+ private List<Completion> completions;
/**
* The provider we're getting completions for.
@@ -54,7 +54,7 @@ public class CompletionXMLParser extends DefaultHandler {
private String paramName;
private String paramType;
private StringBuffer paramDesc;
- private List params;
+ private List<ParameterizedCompletion.Parameter> params;
private String definedIn;
private boolean doingKeywords;
private boolean inKeyword;
@@ -112,8 +112,8 @@ public class CompletionXMLParser extends DefaultHandler {
// May also be null, but that's okay.
completionCL = DEFAULT_COMPLETION_CLASS_LOADER;
}
- completions = new ArrayList();
- params = new ArrayList(1);
+ completions = new ArrayList<Completion>();
+ params = new ArrayList<ParameterizedCompletion.Parameter>(1);
desc = new StringBuffer();
paramDesc = new StringBuffer();
returnValDesc = new StringBuffer();
@@ -143,7 +143,7 @@ public class CompletionXMLParser extends DefaultHandler {
FunctionCompletion fc = null;
if (funcCompletionType!=null) {
try {
- Class clazz = null;
+ Class<?> clazz = null;
if (completionCL!=null) {
clazz = Class.forName(funcCompletionType, true,
completionCL);
@@ -151,11 +151,10 @@ public class CompletionXMLParser extends DefaultHandler {
else {
clazz = Class.forName(funcCompletionType);
}
- Class[] paramTypes = { CompletionProvider.class,
- String.class, String.class };
- Constructor c = clazz.getDeclaredConstructor(paramTypes);
- fc = (FunctionCompletion)c.newInstance(
- new Object[] { provider, name, returnType });
+ Constructor<?> c = clazz.getDeclaredConstructor(
+ CompletionProvider.class, String.class, String.class);
+ fc = (FunctionCompletion)c.newInstance(provider, name,
+ returnType);
} catch (RuntimeException re) { // FindBugs
throw re;
} catch (Exception e) {
@@ -299,7 +298,7 @@ public class CompletionXMLParser extends DefaultHandler {
*
* @return The completions.
*/
- public List getCompletions() {
+ public List<Completion> getCompletions() {
return completions;
}
diff --git a/src/org/fife/ui/autocomplete/DefaultCompletionProvider.java b/src/org/fife/ui/autocomplete/DefaultCompletionProvider.java
index 3265188..4cf8f5c 100644
--- a/src/org/fife/ui/autocomplete/DefaultCompletionProvider.java
+++ b/src/org/fife/ui/autocomplete/DefaultCompletionProvider.java
@@ -52,7 +52,7 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
* wiggles the mouse while a tool tip is displayed, this method gets
* repeatedly called. It can be costly so we try to speed it up a tad).
*/
- private List lastParameterizedCompletionsAt;
+ private List<Completion> lastParameterizedCompletionsAt;
/**
* Constructor. The returned provider will not be aware of any completions.
@@ -120,7 +120,7 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
/**
* {@inheritDoc}
*/
- public List getCompletionsAt(JTextComponent tc, Point p) {
+ public List<Completion> getCompletionsAt(JTextComponent tc, Point p) {
int offset = tc.viewToModel(p);
if (offset<0 || offset>=tc.getDocument().getLength()) {
@@ -163,7 +163,7 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
}
// Get a list of all Completions matching the text.
- List list = getCompletionByInputText(text);
+ List<Completion> list = getCompletionByInputText(text);
lastCompletionsAtText = text;
return lastParameterizedCompletionsAt = list;
@@ -180,9 +180,10 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
/**
* {@inheritDoc}
*/
- public List getParameterizedCompletions(JTextComponent tc) {
+ public List<ParameterizedCompletion> getParameterizedCompletions(
+ JTextComponent tc) {
- List list = null;
+ List<ParameterizedCompletion> list = null;
// If this provider doesn't support parameterized completions,
// bail out now.
@@ -222,15 +223,15 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
// Get a list of all Completions matching the text, but then
// narrow it down to just the ParameterizedCompletions.
- List l = getCompletionByInputText(text);
+ List<Completion> l = getCompletionByInputText(text);
if (l!=null && !l.isEmpty()) {
for (int i=0; i<l.size(); i++) {
Object o = l.get(i);
if (o instanceof ParameterizedCompletion) {
if (list==null) {
- list = new ArrayList(1);
+ list = new ArrayList<ParameterizedCompletion>(1);
}
- list.add(o);
+ list.add((ParameterizedCompletion)o);
}
}
}
@@ -248,7 +249,7 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
* Initializes this completion provider.
*/
protected void init() {
- completions = new ArrayList();
+ completions = new ArrayList<Completion>();
seg = new Segment();
}
@@ -319,7 +320,7 @@ public class DefaultCompletionProvider extends AbstractCompletionProvider {
try {
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(bin, handler);
- List completions = handler.getCompletions();
+ List<Completion> completions = handler.getCompletions();
addCompletions(completions);
char startChar = handler.getParamStartChar();
if (startChar!=0) {
diff --git a/src/org/fife/ui/autocomplete/FunctionCompletion.java b/src/org/fife/ui/autocomplete/FunctionCompletion.java
index e56b4fa..a3da5f3 100644
--- a/src/org/fife/ui/autocomplete/FunctionCompletion.java
+++ b/src/org/fife/ui/autocomplete/FunctionCompletion.java
@@ -10,7 +10,6 @@ package org.fife.ui.autocomplete;
import java.util.ArrayList;
import java.util.List;
-
import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import javax.swing.text.Position;
@@ -28,7 +27,7 @@ public class FunctionCompletion extends VariableCompletion
/**
* Parameters to the function.
*/
- private List params;
+ private List<Parameter> params;
/**
* A description of the return value of this function.
@@ -210,7 +209,7 @@ public class FunctionCompletion extends VariableCompletion
* {@inheritDoc}
*/
public Parameter getParam(int index) {
- return (Parameter)params.get(index);
+ return params.get(index);
}
@@ -297,10 +296,10 @@ public class FunctionCompletion extends VariableCompletion
* @see #getParam(int)
* @see #getParamCount()
*/
- public void setParams(List params) {
+ public void setParams(List<Parameter> params) {
if (params!=null) {
// Deep copy so parsing can re-use its array.
- this.params = new ArrayList(params);
+ this.params = new ArrayList<Parameter>(params);
}
}
diff --git a/src/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java b/src/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java
index 8cd3ae6..5fc0881 100644
--- a/src/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java
+++ b/src/org/fife/ui/autocomplete/LanguageAwareCompletionProvider.java
@@ -12,6 +12,7 @@ package org.fife.ui.autocomplete;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import javax.swing.text.JTextComponent;
@@ -135,7 +136,7 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase
/**
* {@inheritDoc}
*/
- public List getCompletionsAt(JTextComponent tc, Point p) {
+ public List<Completion> getCompletionsAt(JTextComponent tc, Point p) {
return defaultProvider==null ? null :
defaultProvider.getCompletionsAt(tc, p);
}
@@ -148,13 +149,15 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase
* @return The list of possible completions, or an empty list if there
* are none.
*/
- protected List getCompletionsImpl(JTextComponent comp) {
+ protected List<Completion> getCompletionsImpl(JTextComponent comp) {
if (!(comp instanceof RSyntaxTextArea)) {
- return new ArrayList(0);
+ return new ArrayList<Completion>(0);
}
CompletionProvider provider = getProviderFor(comp);
- return provider!=null ? provider.getCompletions(comp) :
- new ArrayList(0);
+ if (provider!=null) {
+ return provider.getCompletions(comp);
+ }
+ return Collections.emptyList();
}
@@ -184,7 +187,8 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase
/**
* {@inheritDoc}
*/
- public List getParameterizedCompletions(JTextComponent tc) {
+ public List<ParameterizedCompletion> getParameterizedCompletions(
+ JTextComponent tc) {
// Parameterized completions can only come from the "code" completion
// provider. We do not do function/method completions while editing
// strings or comments.
@@ -403,10 +407,10 @@ public class LanguageAwareCompletionProvider extends CompletionProviderBase
String tip = null;
- List completions = getCompletionsAt(textArea, e.getPoint());
+ List<Completion> completions = getCompletionsAt(textArea, e.getPoint());
if (completions!=null && completions.size()>0) {
// Only ever 1 match for us in C...
- Completion c = (Completion)completions.get(0);
+ Completion c = completions.get(0);
tip = c.getToolTipText();
}
diff --git a/src/org/fife/ui/autocomplete/MarkupTagCompletion.java b/src/org/fife/ui/autocomplete/MarkupTagCompletion.java
index 8dce4ae..442f676 100644
--- a/src/org/fife/ui/autocomplete/MarkupTagCompletion.java
+++ b/src/org/fife/ui/autocomplete/MarkupTagCompletion.java
@@ -30,7 +30,7 @@ public class MarkupTagCompletion extends AbstractCompletion {
/**
* Attributes of the tag.
*/
- private List attrs;
+ private List<Parameter> attrs;
/**
@@ -88,7 +88,7 @@ public class MarkupTagCompletion extends AbstractCompletion {
* @see #getAttribute(int)
* @see #getAttributeCount()
*/
- public List getAttributes() {
+ public List<Parameter> getAttributes() {
return attrs;
}
@@ -101,7 +101,7 @@ public class MarkupTagCompletion extends AbstractCompletion {
* @see #getAttributeCount()
*/
public Parameter getAttribute(int index) {
- return (Parameter)attrs.get(index);
+ return attrs.get(index);
}
@@ -231,9 +231,9 @@ public class MarkupTagCompletion extends AbstractCompletion {
* @see #getAttribute(int)
* @see #getAttributeCount()
*/
- public void setAttributes(List attrs) {
+ public void setAttributes(List<Parameter> attrs) {
// Deep copy so parsing can re-use its array.
- this.attrs = new ArrayList(attrs);
+ this.attrs = new ArrayList<Parameter>(attrs);
}
diff --git a/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java b/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
index e3ffaeb..dc80325 100644
--- a/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
+++ b/src/org/fife/ui/autocomplete/ParameterChoicesProvider.java
@@ -33,7 +33,7 @@ public interface ParameterChoicesProvider {
* @return The list of parameters. This may be <code>null</code> for
* "no parameters," but might also be an empty list.
*/
- public List getParameterChoices(JTextComponent tc,
+ public List<Completion> getParameterChoices(JTextComponent tc,
ParameterizedCompletion.Parameter param);
diff --git a/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java b/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
index 897eb5a..6006e85 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionChoicesWindow.java
@@ -18,7 +18,6 @@ import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JList;
@@ -60,7 +59,7 @@ public class ParameterizedCompletionChoicesWindow extends JWindow {
/**
* A list of lists of choices for each parameter.
*/
- private List choicesListList;
+ private List<List<Completion>> choicesListList;
/**
* The scroll pane containing the list.
@@ -71,7 +70,7 @@ public class ParameterizedCompletionChoicesWindow extends JWindow {
* Comparator used to sort completions by their relevance before sorting
* them lexicographically.
*/
- private static final Comparator sortByRelevanceComparator =
+ private static final Comparator<Completion> sortByRelevanceComparator =
new SortByRelevanceComparator();
@@ -166,12 +165,12 @@ public class ParameterizedCompletionChoicesWindow extends JWindow {
}
int paramCount = pc.getParamCount();
- choicesListList = new ArrayList(paramCount);
+ choicesListList = new ArrayList<List<Completion>>(paramCount);
JTextComponent tc = ac.getTextComponent();
for (int i=0; i<paramCount; i++) {
ParameterizedCompletion.Parameter param = pc.getParam(i);
- List choices = pcp.getParameterChoices(tc, param);
+ List<Completion> choices = pcp.getParameterChoices(tc, param);
choicesListList.add(choices);
}
@@ -224,14 +223,13 @@ public class ParameterizedCompletionChoicesWindow extends JWindow {
public void setParameter(int param, String prefix) {
model.clear();
- List temp = new ArrayList();
+ List<Completion> temp = new ArrayList<Completion>();
if (choicesListList!=null && param>=0 && param<choicesListList.size()) {
- List choices = (List)choicesListList.get(param);
+ List<Completion> choices = choicesListList.get(param);
if (choices!=null) {
- for (Iterator i=choices.iterator(); i.hasNext(); ) {
- Completion c = (Completion)i.next();
+ for (Completion c : choices) {
String choice = c.getReplacementText();
if (prefix==null || Util.startsWithIgnoreCase(choice, prefix)) {
temp.add(c);
@@ -240,7 +238,7 @@ public class ParameterizedCompletionChoicesWindow extends JWindow {
}
// Sort completions appropriately.
- Comparator c = null;
+ Comparator<Completion> c = null;
if (/*sortByRelevance*/true) {
c = sortByRelevanceComparator;
}
diff --git a/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java b/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
index 426329e..75a0634 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
@@ -18,7 +18,6 @@ import java.awt.event.FocusListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
@@ -98,9 +97,9 @@ class ParameterizedCompletionContext {
/**
* The tags for the highlights around parameters.
*/
- private List tags;
+ private List<Object> tags;
- private List paramCopyInfos;
+ private List<ParamCopyInfo> paramCopyInfos;
private transient boolean ignoringDocumentEvents;
@@ -180,8 +179,8 @@ class ParameterizedCompletionContext {
endingP = new OutlineHighlightPainter(
sc.getParameterizedCompletionCursorPositionColor());
paramCopyP = new ChangeableHighlightPainter(sc.getParameterCopyColor());
- tags = new ArrayList(1); // Usually small
- paramCopyInfos = new ArrayList(1);
+ tags = new ArrayList<Object>(1); // Usually small
+ paramCopyInfos = new ArrayList<ParamCopyInfo>(1);
}
@@ -276,12 +275,11 @@ class ParameterizedCompletionContext {
* <code>null</code> if the offset is not in a parameter.
*/
public String getArgumentText(int offs) {
- List paramHighlights = getParameterHighlights();
+ List<Highlight> paramHighlights = getParameterHighlights();
if (paramHighlights==null || paramHighlights.size()==0) {
return null;
}
- for (int i=0; i<paramHighlights.size(); i++) {
- Highlight h = (Highlight)paramHighlights.get(i);
+ for (Highlight h : paramHighlights) {
if (offs>=h.getStartOffset() && offs<=h.getEndOffset()) {
int start = h.getStartOffset() + 1;
int len = h.getEndOffset() - start;
@@ -315,9 +313,8 @@ class ParameterizedCompletionContext {
dot--; // Workaround for Java Highlight issues
}
- List paramHighlights = getParameterHighlights();
- for (int i=0; i<paramHighlights.size(); i++) {
- Highlight h = (Highlight)paramHighlights.get(i);
+ List<Highlight> paramHighlights = getParameterHighlights();
+ for (Highlight h : paramHighlights) {
if (dot>=h.getStartOffset() && dot<h.getEndOffset()) {
return h;
}
@@ -336,9 +333,9 @@ class ParameterizedCompletionContext {
dot--; // Workaround for Java Highlight issues
}
- List paramHighlights = getParameterHighlights();
+ List<Highlight> paramHighlights = getParameterHighlights();
for (int i=0; i<paramHighlights.size(); i++) {
- Highlight h = (Highlight)paramHighlights.get(i);
+ Highlight h = paramHighlights.get(i);
if (dot>=h.getStartOffset() && dot<h.getEndOffset()) {
return i;
}
@@ -372,11 +369,11 @@ class ParameterizedCompletionContext {
* @return The highlight that comes first in the document.
* @see #getLastHighlight(List)
*/
- private static final int getFirstHighlight(List highlights) {
+ private static final int getFirstHighlight(List<Highlight> highlights) {
int first = -1;
Highlight firstH = null;
for (int i=0; i<highlights.size(); i++) {
- Highlight h = (Highlight)highlights.get(i);
+ Highlight h = highlights.get(i);
if (firstH==null || h.getStartOffset()<firstH.getStartOffset()) {
firstH = h;
first = i;
@@ -396,11 +393,11 @@ class ParameterizedCompletionContext {
* @return The highlight that comes last in the document.
* @see #getFirstHighlight(List)
*/
- private static final int getLastHighlight(List highlights) {
+ private static final int getLastHighlight(List<Highlight> highlights) {
int last = -1;
Highlight lastH = null;
for (int i=highlights.size()-1; i>=0; i--) {
- Highlight h = (Highlight)highlights.get(i);
+ Highlight h = highlights.get(i);
if (lastH==null || h.getStartOffset()>lastH.getStartOffset()) {
lastH = h;
last = i;
@@ -410,8 +407,8 @@ class ParameterizedCompletionContext {
}
- public List getParameterHighlights() {
- List paramHighlights = new ArrayList(2);
+ public List<Highlight> getParameterHighlights() {
+ List<Highlight> paramHighlights = new ArrayList<Highlight>(2);
JTextComponent tc = ac.getTextComponent();
Highlight[] highlights = tc.getHighlighter().getHighlights();
for (int i=0; i<highlights.length; i++) {
@@ -532,9 +529,9 @@ class ParameterizedCompletionContext {
Highlight currentNext = null;
int pos = -1;
- List highlights = getParameterHighlights();
+ List<Highlight> highlights = getParameterHighlights();
for (int i=0; i<highlights.size(); i++) {
- Highlight hl = (Highlight)highlights.get(i);
+ Highlight hl = highlights.get(i);
// Check "< dot", not "<= dot" as OutlineHighlightPainter paints
// starting at one char AFTER the highlight starts, to work around
// Java issue. Thanks to Matthew Adereth!
@@ -549,7 +546,7 @@ class ParameterizedCompletionContext {
// No params after caret - go to first one
if (currentNext.getStartOffset()+1<=dot) {
int nextIndex = getFirstHighlight(highlights);
- currentNext = (Highlight)highlights.get(nextIndex);
+ currentNext = highlights.get(nextIndex);
pos = 0;
}
@@ -580,10 +577,10 @@ class ParameterizedCompletionContext {
int selStart = tc.getSelectionStart()-1; // Workaround for Java Highlight issues.
Highlight currentPrev = null;
int pos = 0;
- List highlights = getParameterHighlights();
+ List<Highlight> highlights = getParameterHighlights();
for (int i=0; i<highlights.size(); i++) {
- Highlight h = (Highlight)highlights.get(i);
+ Highlight h = highlights.get(i);
if (currentPrev==null || currentPrev.getStartOffset()>=dot ||
(h.getStartOffset()<selStart &&
(h.getStartOffset()>currentPrev.getStartOffset() ||
@@ -598,7 +595,7 @@ class ParameterizedCompletionContext {
//if (pos==0 && lastSelectedParam==0 && highlights.size()>1) {
if (pos==firstIndex && lastSelectedParam==firstIndex && highlights.size()>1) {
pos = getLastHighlight(highlights);
- currentPrev = (Highlight)highlights.get(pos);
+ currentPrev = highlights.get(pos);
// "+1" is a workaround for Java Highlight issues.
tc.setSelectionStart(currentPrev.getStartOffset()+1);
tc.setSelectionEnd(currentPrev.getEndOffset());
@@ -632,8 +629,8 @@ class ParameterizedCompletionContext {
}
// Get the current value of the current parameter.
- List paramHighlights = getParameterHighlights();
- Highlight h = (Highlight)paramHighlights.get(index);
+ List<Highlight> paramHighlights = getParameterHighlights();
+ Highlight h = paramHighlights.get(index);
int start = h.getStartOffset() + 1; // param offsets are offset (!) by 1
int len = h.getEndOffset() - start;
String replacement = null;
@@ -645,8 +642,7 @@ class ParameterizedCompletionContext {
// Replace any param copies tracking this parameter with the
// value of this parameter.
- for (Iterator i=paramCopyInfos.iterator(); i.hasNext(); ) {
- ParamCopyInfo pci = (ParamCopyInfo)i.next();
+ for (ParamCopyInfo pci : paramCopyInfos) {
if (pci.paramName.equals(param.getName())) {
pci.h = replaceHighlightedText(doc, pci.h, replacement);
}
@@ -706,8 +702,7 @@ class ParameterizedCompletionContext {
h.removeHighlight(tags.get(i));
}
tags.clear();
- for (int i=0; i<paramCopyInfos.size(); i++) {
- ParamCopyInfo pci = (ParamCopyInfo)paramCopyInfos.get(i);
+ for (ParamCopyInfo pci : paramCopyInfos) {
h.removeHighlight(pci.h);
}
paramCopyInfos.clear();
@@ -817,9 +812,9 @@ class ParameterizedCompletionContext {
int index = -1;
String paramPrefix = null;
- List paramHighlights = getParameterHighlights();
+ List<Highlight> paramHighlights = getParameterHighlights();
for (int i=0; i<paramHighlights.size(); i++) {
- Highlight h = (Highlight)paramHighlights.get(i);
+ Highlight h = paramHighlights.get(i);
// "+1" because of param hack - see OutlineHighlightPainter
int start = h.getStartOffset()+1;
if (dot>=start && dot<=h.getEndOffset()) {
diff --git a/src/org/fife/ui/autocomplete/ParameterizedCompletionInsertionInfo.java b/src/org/fife/ui/autocomplete/ParameterizedCompletionInsertionInfo.java
index f7e3a94..df4fc83 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionInsertionInfo.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionInsertionInfo.java
@@ -31,8 +31,8 @@ class ParameterizedCompletionInsertionInfo {
private int selStart;
private int selEnd;
private String textToInsert;
- private List replacementLocations;
- private List replacementCopies;
+ private List<DocumentRange> replacementLocations;
+ private List<ReplacementCopy> replacementCopies;
public ParameterizedCompletionInsertionInfo() {
@@ -42,7 +42,7 @@ class ParameterizedCompletionInsertionInfo {
public void addReplacementCopy(String id, int start, int end) {
if (replacementCopies==null) {
- replacementCopies = new ArrayList(1);
+ replacementCopies = new ArrayList<ReplacementCopy>(1);
}
replacementCopies.add(new ReplacementCopy(id, start, end));
}
@@ -59,7 +59,7 @@ class ParameterizedCompletionInsertionInfo {
*/
public void addReplacementLocation(int start, int end) {
if (replacementLocations==null) {
- replacementLocations = new ArrayList(1);
+ replacementLocations = new ArrayList<DocumentRange>(1);
}
replacementLocations.add(new DocumentRange(start, end));
}
@@ -110,7 +110,7 @@ class ParameterizedCompletionInsertionInfo {
public ReplacementCopy getReplacementCopy(int index) {
- return (ReplacementCopy)replacementCopies.get(index);
+ return replacementCopies.get(index);
}
@@ -123,7 +123,7 @@ class ParameterizedCompletionInsertionInfo {
* @see #getReplacementCount()
*/
public DocumentRange getReplacementLocation(int index) {
- return (DocumentRange)replacementLocations.get(index);
+ return replacementLocations.get(index);
}
diff --git a/src/org/fife/ui/autocomplete/SortByRelevanceComparator.java b/src/org/fife/ui/autocomplete/SortByRelevanceComparator.java
index b4aa768..ecf8b21 100644
--- a/src/org/fife/ui/autocomplete/SortByRelevanceComparator.java
+++ b/src/org/fife/ui/autocomplete/SortByRelevanceComparator.java
@@ -19,12 +19,10 @@ import java.util.Comparator;
* @author Robert Futrell
* @version 1.0
*/
-public class SortByRelevanceComparator implements Comparator {
+public class SortByRelevanceComparator implements Comparator<Completion> {
- public int compare(Object o1, Object o2) {
- Completion c1 = (Completion)o1;
- Completion c2 = (Completion)o2;
+ public int compare(Completion c1, Completion c2) {
int rel1 = c1.getRelevance();
int rel2 = c2.getRelevance();
int diff = rel2 - rel1;//rel1 - rel2;
diff --git a/src/org/fife/ui/autocomplete/TemplateCompletion.java b/src/org/fife/ui/autocomplete/TemplateCompletion.java
index 507b2da..d2ebcab 100644
--- a/src/org/fife/ui/autocomplete/TemplateCompletion.java
+++ b/src/org/fife/ui/autocomplete/TemplateCompletion.java
@@ -60,7 +60,7 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
public class TemplateCompletion extends AbstractCompletion
implements ParameterizedCompletion {
- private List pieces;
+ private List<TemplatePiece> pieces;
private String inputText;
@@ -73,7 +73,7 @@ public class TemplateCompletion extends AbstractCompletion
/**
* The template's parameters.
*/
- private List params;
+ private List<Parameter> params;
public TemplateCompletion(CompletionProvider provider,
@@ -90,8 +90,8 @@ public class TemplateCompletion extends AbstractCompletion
this.definitionString = definitionString;
this.shortDescription = shortDescription;
this.summary = summary;
- pieces = new ArrayList(3);
- params = new ArrayList(3);
+ pieces = new ArrayList<TemplatePiece>(3);
+ params = new ArrayList<Parameter>(3);
parse(template);
}
@@ -112,7 +112,7 @@ public class TemplateCompletion extends AbstractCompletion
private String getPieceText(int index, String leadingWS) {
- TemplatePiece piece = (TemplatePiece)pieces.get(index);
+ TemplatePiece piece = pieces.get(index);
String text = piece.getText();
if (text.indexOf('\n')>-1) {
text = text.replaceAll("\n", "\n" + leadingWS);
@@ -190,7 +190,7 @@ public class TemplateCompletion extends AbstractCompletion
// performance and simplicity of undo/redo).
int start = dot;
for (int i=0; i<pieces.size(); i++) {
- TemplatePiece piece = (TemplatePiece)pieces.get(i);
+ TemplatePiece piece = pieces.get(i);
String text = getPieceText(i, leadingWS);
if (piece instanceof Text) {
if (replaceTabsWithSpaces) {
@@ -246,7 +246,7 @@ public class TemplateCompletion extends AbstractCompletion
* {@inheritDoc}
*/
public Parameter getParam(int index) {
- return (Parameter)params.get(index);
+ return params.get(index);
}
diff --git a/src/org/fife/ui/autocomplete/Util.java b/src/org/fife/ui/autocomplete/Util.java
index 8821aee..65a03df 100644
--- a/src/org/fife/ui/autocomplete/Util.java
+++ b/src/org/fife/ui/autocomplete/Util.java
@@ -118,15 +118,14 @@ public class Util {
desktopCreationAttempted = true;
try {
- Class desktopClazz = Class.forName("java.awt.Desktop");
+ Class<?> desktopClazz = Class.forName("java.awt.Desktop");
Method m = desktopClazz.
- getDeclaredMethod("isDesktopSupported", null);
+ getDeclaredMethod("isDesktopSupported");
- boolean supported = ((Boolean)m.invoke(null, null)).
- booleanValue();
+ boolean supported= ((Boolean)m.invoke(null)).booleanValue();
if (supported) {
- m = desktopClazz.getDeclaredMethod("getDesktop", null);
- desktop = m.invoke(null, null);
+ m = desktopClazz.getDeclaredMethod("getDesktop");
+ desktop = m.invoke(null);
}
} catch (RuntimeException re) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/autocomplete.git
More information about the pkg-java-commits
mailing list