Skip to content

Commit

Permalink
address another set of error-prone warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lsf37 committed Jan 2, 2020
1 parent 733ee56 commit c6bfaa6
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 30 deletions.
8 changes: 4 additions & 4 deletions jflex/src/main/java/jflex/core/AbstractLexScan.java
Expand Up @@ -2,10 +2,11 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import java_cup.runtime.Symbol;
import jflex.core.unicode.CharClasses;
import jflex.core.unicode.ILexScan;
Expand All @@ -22,8 +23,7 @@ public abstract class AbstractLexScan implements ILexScan {

File file;

@SuppressWarnings("JdkObsolete")
private final Stack<File> files = new Stack<>();
private final Deque<File> files = new ArrayDeque<>();

StringBuilder userCode = new StringBuilder();

Expand Down Expand Up @@ -186,7 +186,7 @@ void includeFile(String filePath) {
throw new ScannerException(file, ErrorMessages.NOT_READABLE, lexLine());
}
// check for cycle
if (files.search(f) > 0) {
if (files.contains(f)) {
throw new ScannerException(file, ErrorMessages.FILE_CYCLE, lexLine());
}
try {
Expand Down
2 changes: 1 addition & 1 deletion jflex/src/main/java/jflex/gui/GeneratorThread.java
Expand Up @@ -35,7 +35,7 @@ public class GeneratorThread extends Thread {
String outputDir;

/** main UI component, likes to be notified when generator finishes */
MainFrame parent;
final MainFrame parent;

/**
* Create a new GeneratorThread, but do not run it yet.
Expand Down
22 changes: 7 additions & 15 deletions jflex/src/main/java/jflex/gui/GridPanel.java
Expand Up @@ -10,7 +10,8 @@
package jflex.gui;

import java.awt.*;
import java.util.Vector;
import java.util.ArrayList;
import java.util.List;

/**
* Grid layout manager like GridLayout but with predefinable grid size.
Expand All @@ -28,7 +29,7 @@ public class GridPanel extends Panel implements Handles {
private final int hgap;
private final int vgap;

private final Vector<GridPanelConstraint> constraints = new Vector<>();
private final List<GridPanelConstraint> constraints = new ArrayList<>();
private Insets insets = new Insets(0, 0, 0, 0);

/** {@inheritDoc} */
Expand Down Expand Up @@ -62,7 +63,7 @@ public void doLayout() {
float cellHeight = size.height / rows;

for (int i = 0; i < constraints.size(); i++) {
GridPanelConstraint c = constraints.elementAt(i);
GridPanelConstraint c = constraints.get(i);

float x = cellWidth * c.x + insets.left + hgap / 2;
float y = cellHeight * c.y + insets.right + vgap / 2;
Expand Down Expand Up @@ -124,7 +125,7 @@ public Dimension getPreferredSize() {
float dx = 0;

for (int i = 0; i < constraints.size(); i++) {
GridPanelConstraint c = constraints.elementAt(i);
GridPanelConstraint c = constraints.get(i);

Dimension d = c.component.getPreferredSize();

Expand Down Expand Up @@ -168,18 +169,9 @@ public void add(int x, int y, int dx, int dy, Component c) {
add(x, y, dx, dy, FILL, c);
}

/**
* add.
*
* @param x a int.
* @param y a int.
* @param dx a int.
* @param dy a int.
* @param handle a int.
* @param c a {@link java.awt.Component} object.
*/
/** Add a component to this panel. */
public void add(int x, int y, int dx, int dy, int handle, Component c) {
super.add(c);
constraints.addElement(new GridPanelConstraint(x, y, dx, dy, handle, c));
constraints.add(new GridPanelConstraint(x, y, dx, dy, handle, c));
}
}
8 changes: 6 additions & 2 deletions jflex/src/main/java/jflex/gui/GridPanelConstraint.java
Expand Up @@ -18,8 +18,12 @@
*/
public class GridPanelConstraint {

int x, y, width, height, handle;
Component component;
final int x;
final int y;
final int width;
final int height;
final int handle;
final Component component;

/**
* Constructor for GridPanelConstraint.
Expand Down
1 change: 0 additions & 1 deletion jflex/src/main/java/jflex/gui/MainFrame.java
Expand Up @@ -28,7 +28,6 @@
*/
public final class MainFrame extends Frame implements Handles {

/** */
private static final long serialVersionUID = 3296137982410640865L;

private volatile boolean choosing;
Expand Down
2 changes: 1 addition & 1 deletion jflex/src/main/java/jflex/gui/OptionsDialog.java
Expand Up @@ -32,7 +32,7 @@ public class OptionsDialog extends Dialog {

private static final long serialVersionUID = 6807759416163314769L;

private Frame owner;
private final Frame owner;

private TextField skelFile;

Expand Down
6 changes: 3 additions & 3 deletions jflex/src/main/jflex/skeleton.nested
Expand Up @@ -82,8 +82,8 @@
private int zzFinalHighSurrogate = 0;

/** the stack of open (nested) input streams to read from */
private java.util.Stack<ZzFlexStreamInfo> zzStreams
= new java.util.Stack<ZzFlexStreamInfo>();
private java.util.Deque<ZzFlexStreamInfo> zzStreams
= new java.util.ArrayDeque<ZzFlexStreamInfo>();

/**
* inner class used to store info for nested
Expand Down Expand Up @@ -236,7 +236,7 @@
* Closes the current input stream and continues to
* read from the one on top of the stream stack.
*
* @throws java.util.EmptyStackException
* @throws java.util.NoSuchElementException
* if there is no further stream to read from.
*
* @throws java.io.IOException
Expand Down
2 changes: 1 addition & 1 deletion jflex/src/test/java/jflex/anttask/JFlexTaskTest.java
Expand Up @@ -112,7 +112,7 @@ public void testNobak() {
public void testSkel() {
task.setVerbose(false); // avoid to java console pop up
task.setSkeleton(new File("src/main/jflex/skeleton.nested"));
assertThat(Skeleton.line[3].indexOf("java.util.Stack") > 0).isTrue();
assertThat(Skeleton.line[3].indexOf("java.util.Deque") > 0).isTrue();
}

@Test
Expand Down
4 changes: 2 additions & 2 deletions jflex/src/test/java/jflex/skeleton/SkeletonTest.java
Expand Up @@ -56,8 +56,8 @@ public void readSkelFile_bazel() throws FileNotFoundException {
}

private void checkDefaultSkeleton() {
assertThat(Skeleton.line[3]).contains("java.util.Stack");
assertThat(Skeleton.line[3]).contains("java.util.Deque");
Skeleton.readDefault();
assertThat(Skeleton.line[3]).doesNotContain("java.util.Stack");
assertThat(Skeleton.line[3]).doesNotContain("java.util.Deque");
}
}

0 comments on commit c6bfaa6

Please sign in to comment.