Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to Jline3 #115

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ jdk:
- oraclejdk10
- oraclejdk9
- oraclejdk8
- openjdk7
branches:
only:
- master
Expand Down
2 changes: 1 addition & 1 deletion HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Capitalization is tricky:

## How to make a release (for committers)

Make sure `mvn clean install` and `mvn site` pass under JDK 1.7, 8, 9,
Make sure `mvn clean install` and `mvn site` pass under JDK 8, 9,
10 and 11.

Write release notes. Run the
Expand Down
34 changes: 28 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<docbkx-maven-plugin.version>2.0.17</docbkx-maven-plugin.version>
<h2.version>1.4.191</h2.version>
<hsqldb.version>2.4.1</hsqldb.version>
<jline.version>2.14.4</jline.version>
<jline.version>3.9.0</jline.version>
<jmockit.version>1.30</jmockit.version>
<junit.version>4.12</junit.version>
<maven-assembly-plugin.version>3.0.0</maven-assembly-plugin.version>
Expand Down Expand Up @@ -152,7 +152,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>[1.6,)</version>
<version>[1.8,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.2.1,)</version>
Expand Down Expand Up @@ -206,8 +206,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -262,8 +262,30 @@

<dependencies>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<groupId>org.jline</groupId>
<artifactId>jline-terminal</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
<version>${jline.version}</version>
</dependency>
<!-- required to have terminal with advanced capabilities on Windows -->
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jansi</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jna</artifactId>
<version>${jline.version}</version>
</dependency>
<!-- required to have terminal with advanced capabilities on Windows -->
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline-builtins</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/sqlline/AbstractCommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.Collections;
import java.util.List;

import jline.console.completer.Completer;
import jline.console.completer.NullCompleter;
import org.jline.reader.Completer;
import org.jline.reader.impl.completer.NullCompleter;

/**
* An abstract implementation of CommandHandler.
Expand All @@ -37,9 +37,9 @@ public AbstractCommandHandler(SqlLine sqlLine, String[] names,
this.helpText = helpText;
if (completers == null || completers.size() == 0) {
this.parameterCompleters =
Collections.singletonList((Completer) new NullCompleter());
Collections.singletonList(new NullCompleter());
} else {
List<Completer> c = new ArrayList<Completer>(completers);
List<Completer> c = new ArrayList<>(completers);
c.add(new NullCompleter());
this.parameterCompleters = c;
}
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/sqlline/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
import java.util.SortedSet;
import java.util.TreeSet;

import jline.console.completer.Completer;
import jline.console.completer.FileNameCompleter;
import jline.console.completer.StringsCompleter;
import org.jline.builtins.Completers.FileNameCompleter;
import org.jline.reader.Completer;
import org.jline.reader.impl.completer.StringsCompleter;

/**
* Defines the configuration of a SQLLine application.
Expand Down Expand Up @@ -110,8 +110,7 @@ public class Application {
};

private static final SortedSet<String> DEFAULT_DRIVERS =
Collections.unmodifiableSortedSet(
new TreeSet<String>(Arrays.asList(DRIVERS)));
Collections.unmodifiableSortedSet(new TreeSet<>(Arrays.asList(DRIVERS)));

private static final String[] CONNECTION_URLS = {
"jdbc:JSQLConnect://<hostname>/database=<database>",
Expand Down Expand Up @@ -215,8 +214,7 @@ public Collection<String> initDrivers() {
* @return Map of output formats by name
*/
public Map<String, OutputFormat> getOutputFormats(SqlLine sqlLine) {
final Map<String, OutputFormat> outputFormats =
new HashMap<String, OutputFormat>();
final Map<String, OutputFormat> outputFormats = new HashMap<>();
outputFormats.put("vertical", new VerticalOutputFormat(sqlLine));
outputFormats.put("table", new TableOutputFormat(sqlLine));
outputFormats.put("csv", new SeparatedValuesOutputFormat(sqlLine, ","));
Expand Down Expand Up @@ -311,6 +309,7 @@ public Collection<CommandHandler> getCommandHandlers(SqlLine sqlLine) {
new ReflectiveCommandHandler(sqlLine, empty, "sql"),
new ReflectiveCommandHandler(sqlLine, empty, "call"),
new ReflectiveCommandHandler(sqlLine, empty, "appconfig"),
new ReflectiveCommandHandler(sqlLine, empty, "rerun", "/"),
};
return Collections.unmodifiableList(Arrays.asList(handlers));
}
Expand All @@ -334,7 +333,7 @@ public SqlLineOpts getOpts(SqlLine sqlLine) {

private Set<String> getMetadataMethodNames() {
try {
TreeSet<String> methodNames = new TreeSet<String>();
TreeSet<String> methodNames = new TreeSet<>();
for (Method method : DatabaseMetaData.class.getDeclaredMethods()) {
methodNames.add(method.getName());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sqlline/BufferedRows.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BufferedRows extends Rows {
BufferedRows(SqlLine sqlLine, ResultSet rs) throws SQLException {
super(sqlLine, rs);

list = new LinkedList<Row>();
list = new LinkedList<>();

int count = rsMeta.getColumnCount();

Expand Down
18 changes: 11 additions & 7 deletions src/main/java/sqlline/ClassNameCompleter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import jline.console.completer.StringsCompleter;
import org.jline.reader.Candidate;
import org.jline.reader.impl.completer.StringsCompleter;
import org.jline.utils.AttributedString;

/**
* An implementation of {@link jline.console.completer.Completer} that completes
* An implementation of {@link org.jline.reader.Completer} that completes
* java class names. By default, it scans the java class path to locate all the
* classes.
*/
Expand All @@ -33,11 +35,13 @@ public class ClassNameCompleter extends StringsCompleter {
*/
public ClassNameCompleter() throws IOException {
super(getClassNames());
getStrings().add(".");
candidates.add(new Candidate(
AttributedString.stripAnsi("."),
".", null, null, null, null, true));
}

public static Set<String> getClassNames() throws IOException {
Set<URL> urls = new HashSet<URL>();
Set<URL> urls = new HashSet<>();

for (ClassLoader loader = ClassNameCompleter.class.getClassLoader();
loader != null;
Expand Down Expand Up @@ -68,13 +72,13 @@ public static Set<String> getClassNames() throws IOException {
}
}

Set<String> classes = new HashSet<String>();
Set<String> classes = new HashSet<>();
for (URL url : urls) {
File file = new File(URLDecoder.decode(url.getFile(), "UTF-8"));

if (file.isDirectory()) {
Set<String> files = getClassFiles(file.getAbsolutePath(),
new HashSet<String>(),
new HashSet<>(),
file,
new int[]{200});
classes.addAll(files);
Expand Down Expand Up @@ -112,7 +116,7 @@ public static Set<String> getClassNames() throws IOException {

// now filter classes by changing "/" to "." and trimming the
// trailing ".class"
Set<String> classNames = new TreeSet<String>();
Set<String> classNames = new TreeSet<>();

for (String name : classes) {
classNames.add(name.replace('/', '.').substring(0, name.length() - 6));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sqlline/ColorBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum ColorAttr {
}
}

private final List<Object> parts = new LinkedList<Object>();
private final List<Object> parts = new LinkedList<>();

private final boolean useColor;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/sqlline/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import java.util.List;

import jline.console.completer.Completer;
import org.jline.reader.Completer;

/**
* A generic command to be executed. Execution of the command should be
Expand Down
Loading