Skip to content

Commit 3082b75

Browse files
eclipse-platform-botlaeubi
authored andcommitted
Perform clean code of terminal/bundles/org.eclipse.terminal.connector.process
1 parent d0f29ab commit 3082b75

File tree

4 files changed

+24
-13
lines changed

4 files changed

+24
-13
lines changed

terminal/bundles/org.eclipse.terminal.connector.process/src/org/eclipse/terminal/connector/process/ProcessConnector.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,9 @@ public void connect(ITerminalControl control) {
194194

195195
// Enable VT100 line wrapping if we are connected via pty
196196
// And TERM is VT100 compatible
197-
if (pty != null && !isAnsiTerminal)
197+
if (pty != null && !isAnsiTerminal) {
198198
control.setVT100LineWrapping(true);
199+
}
199200

200201
// connect the streams
201202
connectStreams(control, process.getOutputStream(), process.getInputStream(),
@@ -214,8 +215,9 @@ public void connect(ITerminalControl control) {
214215
Shell shell = control.getShell();
215216
// Lookup the tab item
216217
CTabItem item = ConsoleManager.getInstance().findConsole(control);
217-
if (item != null)
218+
if (item != null) {
218219
item.dispose();
220+
}
219221
// Get the error message from the exception
220222
String msg = e.getLocalizedMessage() != null ? e.getLocalizedMessage() : ""; //$NON-NLS-1$
221223
Assert.isNotNull(msg);
@@ -229,10 +231,13 @@ public void connect(ITerminalControl control) {
229231
}
230232

231233
private static String getTermVariable(String[] envp) {
232-
if (envp != null && !Platform.OS_WIN32.equals(Platform.getOS()))
233-
for (String var : envp)
234-
if (var.startsWith("TERM=")) //$NON-NLS-1$
234+
if (envp != null && !Platform.OS_WIN32.equals(Platform.getOS())) {
235+
for (String var : envp) {
236+
if (var.startsWith("TERM=")) { //$NON-NLS-1$
235237
return var.substring(5);
238+
}
239+
}
240+
}
236241
return "xterm"; //$NON-NLS-1$
237242
}
238243

terminal/bundles/org.eclipse.terminal.connector.process/src/org/eclipse/terminal/connector/process/ProcessLauncherDelegate.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,17 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
6161

6262
// Check for the terminal connector id
6363
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
64-
if (connectorId == null)
64+
if (connectorId == null) {
6565
connectorId = "org.eclipse.terminal.connector.process.ProcessConnector"; //$NON-NLS-1$
66+
}
6667

6768
// Extract the process properties
6869
String image = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_PATH);
6970
String arguments = (String) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_ARGS);
7071
Process process = (Process) properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ);
7172
PTY pty = (PTY) properties.get(ITerminalsConnectorConstants.PROP_PTY_OBJ);
7273
Object value = properties.get(ITerminalsConnectorConstants.PROP_LOCAL_ECHO);
73-
boolean localEcho = value instanceof Boolean ? ((Boolean) value).booleanValue() : false;
74+
boolean localEcho = value instanceof Boolean b ? b.booleanValue() : false;
7475
String lineSeparator = (String) properties.get(ITerminalsConnectorConstants.PROP_LINE_SEPARATOR);
7576
ITerminalServiceOutputStreamMonitorListener[] stdoutListeners = (ITerminalServiceOutputStreamMonitorListener[]) properties
7677
.get(ITerminalsConnectorConstants.PROP_STDOUT_LISTENERS);
@@ -106,7 +107,7 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
106107
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
107108
value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
108109
processSettings
109-
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
110+
.setMergeWithNativeEnvironment(value instanceof Boolean b ? b.booleanValue() : false);
110111
}
111112

112113
// And save the settings to the store

terminal/bundles/org.eclipse.terminal.connector.process/src/org/eclipse/terminal/connector/process/ProcessMonitor.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ public void dispose() {
4848
// Set the disposed status
4949
disposed = true;
5050
// Not initialized -> return immediately
51-
if (thread == null)
51+
if (thread == null) {
5252
return;
53+
}
5354

5455
// Copy the reference
5556
final Thread oldThread = thread;
@@ -64,8 +65,9 @@ public void dispose() {
6465
*/
6566
public void startMonitoring() {
6667
// If already initialized -> return immediately
67-
if (thread != null)
68+
if (thread != null) {
6869
return;
70+
}
6971

7072
// Create a new runnable which is constantly reading from the stream
7173
Runnable runnable = () -> monitorProcess();
@@ -86,8 +88,9 @@ public void startMonitoring() {
8688
*/
8789
public void monitorProcess() {
8890
// If already disposed -> return immediately
89-
if (disposed)
91+
if (disposed) {
9092
return;
93+
}
9194

9295
try {
9396
// Wait for the monitored process to terminate
@@ -97,8 +100,9 @@ public void monitorProcess() {
97100
Thread.interrupted();
98101
} finally {
99102
// Dispose the parent process connector
100-
if (!disposed)
103+
if (!disposed) {
101104
processConnector.disconnect();
105+
}
102106
}
103107
}
104108
}

terminal/bundles/org.eclipse.terminal.connector.process/src/org/eclipse/terminal/connector/process/ProcessSettings.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,9 @@ public Process getProcess() {
113113
public void setPTY(PTY pty) {
114114
this.pty = pty;
115115
// If the PTY is set to "null", the local echo will be set to "true"
116-
if (pty == null)
116+
if (pty == null) {
117117
setLocalEcho(true);
118+
}
118119
}
119120

120121
/**

0 commit comments

Comments
 (0)