Skip to content

Commit

Permalink
[NETBEANS-3807] - cleanup ArrayList rawtype warnings (apache#1982)
Browse files Browse the repository at this point in the history
This change cleans up the following warning:

  [repeat] /home/bwalker/src/netbeans/webcommon/javascript2.model/src/org/netbeans/modules/javascript2/model/ModelVisitor.java:1454: warning: [rawt
ypes] found raw type: ArrayList
  [repeat]             private List<VarNode> declaredVars = new ArrayList();
  [repeat]                                                      ^
  [repeat]   missing type arguments for generic class ArrayList<E>
  [repeat]   where E is a type-variable:
  [repeat]     E extends Object declared in class ArrayList
  • Loading branch information
BradWalker authored Feb 26, 2020
1 parent 5e72bd0 commit 11a439b
Show file tree
Hide file tree
Showing 26 changed files with 75 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ protected void removeNotify() {
}

private void refreshList() {
List keys = new ArrayList();
List<Node> keys = new ArrayList<>();
Node[] origChildren = original.getChildren().getNodes();
for (Node node : origChildren) {
keys.add(node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public boolean readResponse(InputStream in, HttpURLConnection hconn) {
protected boolean processResponse() {
// Make ArrayList copy of stored lines. ArrayList allows better access
// to log values.
List logLines = new ArrayList(lines.size());
List<String> logLines = new ArrayList<>(lines.size());
for (String line : lines) {
logLines.add(line);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private static Map createFoldersToSourceGroupsMap(final SourceGroup[] sourceGrou
private static List<SourceGroup> getTestTargets(SourceGroup sourceGroup, Map foldersToSourceGroupsMap) {
final URL[] rootURLs = UnitTestForSourceQuery.findUnitTests(sourceGroup.getRootFolder());
if (rootURLs.length == 0) {
return new ArrayList();
return new ArrayList<SourceGroup>();
}
List<SourceGroup> result = new ArrayList<>();
List<FileObject> sourceRoots = getFileObjects(rootURLs, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
public class ExtFormatter extends Formatter implements FormatLayer {

/** List holding the format layers */
private List formatLayerList = new ArrayList();
private List<FormatLayer> formatLayerList = new ArrayList<>();

/** Use this instead of testing by containsKey() */
private static final Object NULL_VALUE = new Object();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.netbeans.editor.ext;

import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import javax.swing.text.Position;
import org.netbeans.editor.TokenItem;
Expand All @@ -43,16 +44,16 @@ class FormatTokenPositionSupport {
private SaveSet lastSet;

/** Map holding the [token, token-position-list] pairs. */
private final HashMap<TokenItem, ArrayList> tokens2positionLists = new HashMap<>();
private final HashMap<TokenItem, List<ExtTokenPosition>> tokens2positionLists = new HashMap<>();

FormatTokenPositionSupport(FormatWriter formatWriter) {
this.formatWriter = formatWriter;
}

private ArrayList getPosList(TokenItem token) {
ArrayList ret = (ArrayList)tokens2positionLists.get(token);
private List<ExtTokenPosition> getPosList(TokenItem token) {
List<ExtTokenPosition> ret = tokens2positionLists.get(token);
if (ret == null) {
ret = new ArrayList(3);
ret = new ArrayList<>(3);
tokens2positionLists.put(token, ret);
}
return ret;
Expand All @@ -77,7 +78,7 @@ synchronized ExtTokenPosition getTokenPosition(TokenItem token, int offset,
+ " >= tokenLength=" + token.getImage().length()); // NOI18N
}

ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int cnt = posList.size();
ExtTokenPosition etp;
for (int i = 0; i < cnt; i++) {
Expand Down Expand Up @@ -105,9 +106,9 @@ synchronized void splitStartTokenPositions(TokenItem token, int startLength) {
if (prevToken != null) {
prevToken = formatWriter.findNonEmptyToken(prevToken, true);
}
ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int len = posList.size();
ArrayList prevPosList = getPosList(prevToken);
List<ExtTokenPosition> prevPosList = getPosList(prevToken);
for (int i = 0; i < len; i++) {
ExtTokenPosition etp = (ExtTokenPosition)posList.get(i);
if (etp.offset < startLength) { // move to prevToken
Expand All @@ -133,9 +134,9 @@ synchronized void splitEndTokenPositions(TokenItem token, int endLength) {
if (nextToken != null) {
nextToken = formatWriter.findNonEmptyToken(nextToken, false);
}
ArrayList nextPosList = getPosList(nextToken);
List<ExtTokenPosition> nextPosList = getPosList(nextToken);

ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int len = posList.size();
int offset = token.getImage().length() - endLength;
for (int i = 0; i < len; i++) {
Expand All @@ -153,7 +154,7 @@ synchronized void splitEndTokenPositions(TokenItem token, int endLength) {

/** Text in the token will be inserted. */
synchronized void tokenTextInsert(TokenItem token, int offset, int length) {
ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int len = posList.size();
// Add length to all positions after insertion point
for (int i = 0; i < len; i++) {
Expand Down Expand Up @@ -186,10 +187,10 @@ synchronized void tokenTextInsert(TokenItem token, int offset, int length) {

/** Text in the token will be removed. */
synchronized void tokenTextRemove(TokenItem token, int offset, int length) {
ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int len = posList.size();
int newLen = token.getImage().length() - length;
ArrayList nextList = getPosList(token.getNext());
List<ExtTokenPosition> nextList = getPosList(token.getNext());
for (int i = 0; i < len; i++) {
ExtTokenPosition etp = (ExtTokenPosition)posList.get(i);
if (etp.offset >= offset + length) { // move to nextToken
Expand Down Expand Up @@ -217,9 +218,9 @@ synchronized void tokenRemove(TokenItem token) {
if (nextToken != null) {
nextToken = formatWriter.findNonEmptyToken(nextToken, false);
}
ArrayList nextPosList = getPosList(nextToken);
List<ExtTokenPosition> nextPosList = getPosList(nextToken);

ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);
int len = posList.size();
for (int i = 0; i < len; i++) {
ExtTokenPosition etp = (ExtTokenPosition)posList.get(i);
Expand All @@ -236,13 +237,13 @@ synchronized void tokenRemove(TokenItem token) {
/** Given token was inserted into the chain */
synchronized void tokenInsert(TokenItem token) {
if (token.getImage().length() > 0) { // only for non-zero size
ArrayList posList = getPosList(token);
List<ExtTokenPosition> posList = getPosList(token);

TokenItem nextToken = token.getNext();
if (nextToken != null) {
nextToken = formatWriter.findNonEmptyToken(nextToken, false);
}
ArrayList nextPosList = getPosList(nextToken);
List<ExtTokenPosition> nextPosList = getPosList(nextToken);

int nextLen = nextPosList.size();
for (int i = 0; i < nextLen; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public void checkExpandFolds(JTextComponent c, List<Position> posList) {
endOffset = offset;
}
Iterator collapsedFoldIterator = FoldUtilities.collapsedFoldIterator(foldHierarchy, offset, endOffset);
List foldsToExpand;
List<Fold> foldsToExpand;
Fold lastFold;
boolean lastFoldExpandAdded = false;
if (collapsedFoldIterator.hasNext()) {
lastFold = (Fold) collapsedFoldIterator.next();
foldsToExpand = new ArrayList(2);
foldsToExpand = new ArrayList<>(2);
} else {
lastFold = null;
foldsToExpand = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ private synchronized void refreshModel(DebuggerEngine e) {
models.add(joinLists(treeModelFilters));
}
synchronized (treeExpansionModels) {
models.add(new ArrayList(treeExpansionModels));
models.add(new ArrayList<Object>(treeExpansionModels));
}
synchronized (nodeModels) {
models.add(joinLists(nodeModels));
Expand All @@ -563,25 +563,25 @@ private synchronized void refreshModel(DebuggerEngine e) {
models.add(joinLists(tableModels));
}
synchronized (tableModelFilters) {
models.add(new ArrayList(tableModelFilters));
models.add(new ArrayList<Object>(tableModelFilters));
}
synchronized (nodeActionsProviders) {
models.add(new ArrayList(nodeActionsProviders));
models.add(new ArrayList<Object>(nodeActionsProviders));
}
synchronized (nodeActionsProviderFilters) {
models.add(new ArrayList(nodeActionsProviderFilters));
models.add(new ArrayList<Object>(nodeActionsProviderFilters));
}
synchronized (columnModels) {
models.add(new ArrayList(columnModels));
models.add(new ArrayList<Object>(columnModels));
}
synchronized (mm) {
models.add(new ArrayList(mm));
models.add(new ArrayList<Object>(mm));
}
synchronized (treeExpansionModelFilters) {
models.add(new ArrayList(treeExpansionModelFilters));
models.add(new ArrayList<Object>(treeExpansionModelFilters));
}
synchronized (asynchModelFilters) {
models.add(new ArrayList(asynchModelFilters));
models.add(new ArrayList<Object>(asynchModelFilters));
}
synchronized (tableRenderers) {
models.add(new ArrayList(tableRenderers));
Expand Down
2 changes: 1 addition & 1 deletion ide/target.iterator/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# specific language governing permissions and limitations
# under the License.
is.autoload=true
javac.source=1.6
javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyVetoException;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -346,7 +347,7 @@ private Collection getKeys() {
else {
FileObject files[] = fo.getChildren();
Arrays.sort(files,new BrowseFolders.FileObjectComparator());
ArrayList children = new ArrayList( files.length );
List<Key> children = new ArrayList<>(files.length);

if (BrowseFolders.this.target==DataFolder.class)
for( int i = 0; i < files.length; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class CatalogMounterModel extends Object {

private ComboBoxModel cxModel = null; // model containig CatalogMounterModel.Entries

private List changeListeners = new ArrayList(2);
private List<ChangeListener> changeListeners = new ArrayList<>(2);


/** Creates new CatalogMounterModel */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.netbeans.modules.ant.debugger.breakpoints;

import java.beans.PropertyChangeEvent;
import java.util.List;
import java.util.ArrayList;
import org.netbeans.api.debugger.Breakpoint;
import org.netbeans.api.debugger.DebuggerEngine;
Expand Down Expand Up @@ -134,7 +135,7 @@ private static Breakpoint[] getBreakpoints () {
Breakpoint[] bs = DebuggerManager.getDebuggerManager ().
getBreakpoints ();
int i, k = bs.length;
ArrayList bb = new ArrayList ();
List<Breakpoint> bb = new ArrayList<>();
for (i = 0; i < k; i++)
// Don't store hidden breakpoints
if (bs[i] instanceof AntBreakpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void change(List c, int action) {
DBElement[] oldElements = getElements();
int oldLength = (oldElements == null) ? 0 : oldElements.length;
int newLength = (c == null) ? 0 : c.size();
List list = null;
List<DBElement> list = null;

switch (action) {
case DBElement.Impl.ADD:
Expand All @@ -86,7 +86,7 @@ protected void change(List c, int action) {
break;
case TableElement.Impl.REMOVE:
if (newLength > 0 && oldLength > 0) {
list = new ArrayList(Arrays.asList(oldElements));
list = new ArrayList<>(Arrays.asList(oldElements));
list.removeAll(c);
hasChange = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.netbeans.modules.dbschema;

import java.util.List;
import java.util.ArrayList;
import java.util.ResourceBundle;
import java.text.MessageFormat;
Expand Down Expand Up @@ -367,14 +368,14 @@ public KeyElement getKey(DBIdentifier name) {
* @param subtype the type of the key classes
* @return the keys of the given subtype or <code>null</code> if not found
*/
private ArrayList getKeys(Class subtype) {
private List<KeyElement> getKeys(Class subtype) {
KeyElement[] keys = getKeys();

if (keys == null)
return null;

int i, count = keys.length;
ArrayList subKeys = new ArrayList(count);
List<KeyElement> subKeys = new ArrayList<>(count);

for (i = 0; i < count; i++) {
KeyElement key = keys[i];
Expand All @@ -390,7 +391,7 @@ private ArrayList getKeys(Class subtype) {
* @return the foreign keys or <code>null</code> if not found
*/
public ForeignKeyElement[] getForeignKeys() {
ArrayList keys = getKeys(ForeignKeyElement.class);
List<KeyElement> keys = getKeys(ForeignKeyElement.class);

if (keys == null)
return null;
Expand Down Expand Up @@ -422,7 +423,7 @@ public ForeignKeyElement getForeignKey(DBIdentifier name) {
* @return the unique keys or <code>null</code> if not found
*/
public UniqueKeyElement[] getUniqueKeys() {
ArrayList keys = getKeys(UniqueKeyElement.class);
List<KeyElement> keys = getKeys(UniqueKeyElement.class);

if (keys == null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public void changeElements(List elems, int action) {
DBElement[] oldElements = getElements();
int oldLength = (oldElements == null) ? 0 : oldElements.length;
int newLength = (elems == null) ? 0 : elems.size();
List list = null;
List<DBElement> list = null;

switch (action) {
case DBElement.Impl.ADD:
if (newLength > 0) {
list = ((oldLength == 0) ? new ArrayList() : new ArrayList(Arrays.asList(oldElements)));
list = ((oldLength == 0) ? new ArrayList<DBElement>() : new ArrayList<DBElement>(Arrays.asList(oldElements)));
list.addAll(elems);
changed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ private void initViews(ConnectionProvider cp, LinkedList views, DDLBridge bridge
}

private List getOracleRecycleBinTables() {
List result = new ArrayList();
List<String> result = new ArrayList<>();
try {
if ( dmd.getDatabaseMajorVersion() < 10 ) {
return Collections.EMPTY_LIST;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ public static List getSourceViews(AntProjectHelper helper, String style) {
*/
public static void putSourceViews(AntProjectHelper helper, List<SourceFolder> sources, String style) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element viewEl = XMLUtil.findElement(data, "view", Util.NAMESPACE); // NOI18N
Expand Down Expand Up @@ -686,7 +685,6 @@ else if (isFolder(evaluator, baseFolder, output2)) {
*/
public static void putExports(AntProjectHelper helper, List<Export> exports) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();

Expand Down Expand Up @@ -764,7 +762,6 @@ public static List<String> guessSubprojects(PropertyEvaluator evaluator,
*/
public static void putSubprojects(AntProjectHelper helper, List<String> subprojects) {
//assert ProjectManager.mutex().isWriteAccess();
ArrayList list = new ArrayList();
Element data = Util.getPrimaryConfigurationData(helper);
Document doc = data.getOwnerDocument();
Element subproject = XMLUtil.findElement(data, "subprojects", Util.NAMESPACE); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public void actionPerformed(ActionEvent e) {
}

private static Object[] createArray(Object ... items) {
ArrayList a = new ArrayList();
List<Object> a = new ArrayList<>();
for (Object o:items) {
if (o!=null)
a.add(o);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public class JShellOptions2 extends javax.swing.JPanel implements ItemListener {
private J2SECategoryExtensionProvider.ConfigChangeListener listener;
private ChangeListener changeListener;
private Map<String, String> changedOptions = new HashMap<>();
private List<JComponent> hideControls = new ArrayList();
private List<JComponent> hideControls = new ArrayList<>();
private ElementHandle<TypeElement> targetClass;
private String oldText;
private ClasspathInfo cpi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static SourceGroup[] getJavaSourceGroups(Project project) {
SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(
JavaProjectConstants.SOURCES_TYPE_JAVA);
Set testGroups = getTestSourceGroups(sourceGroups);
List result = new ArrayList();
List<SourceGroup> result = new ArrayList<>();
for (int i = 0; i < sourceGroups.length; i++) {
if (!testGroups.contains(sourceGroups[i])) {
result.add(sourceGroups[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void addMethod(MethodTree mt) {
if (old instanceof Collection) {
c = (Collection)old;
} else {
methods.put(key, c = new ArrayList());
methods.put(key, c = new ArrayList<Object>());
c.add(old);
}
c.add(mt);
Expand Down
Loading

0 comments on commit 11a439b

Please sign in to comment.