Skip to content

Commit 9b64bb8

Browse files
committed
Fix code style issues
1 parent 03b9949 commit 9b64bb8

File tree

1 file changed

+35
-28
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/helpers

1 file changed

+35
-28
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/helpers/IDEHelperImpl.java

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
package com.microsoft.intellij.helpers;
77

8-
import com.google.common.util.concurrent.*;
8+
import com.google.common.util.concurrent.FutureCallback;
9+
import com.google.common.util.concurrent.Futures;
10+
import com.google.common.util.concurrent.ListenableFuture;
11+
import com.google.common.util.concurrent.MoreExecutors;
12+
import com.google.common.util.concurrent.SettableFuture;
913
import com.intellij.icons.AllIcons;
1014
import com.intellij.ide.BrowserUtil;
1115
import com.intellij.ide.actions.RevealFileAction;
@@ -16,9 +20,7 @@
1620
import com.intellij.openapi.actionSystem.AnAction;
1721
import com.intellij.openapi.actionSystem.AnActionEvent;
1822
import com.intellij.openapi.application.ApplicationManager;
19-
import com.intellij.openapi.compiler.CompileContext;
2023
import com.intellij.openapi.compiler.CompileScope;
21-
import com.intellij.openapi.compiler.CompileStatusNotification;
2224
import com.intellij.openapi.compiler.CompilerManager;
2325
import com.intellij.openapi.fileEditor.FileEditor;
2426
import com.intellij.openapi.fileEditor.FileEditorManager;
@@ -46,8 +48,8 @@
4648
import com.microsoft.azure.toolkit.lib.appservice.model.AppServiceFile;
4749
import com.microsoft.azure.toolkit.lib.appservice.model.AppServiceFileLegacy;
4850
import com.microsoft.azure.toolkit.lib.appservice.service.IAppService;
49-
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
5051
import com.microsoft.azure.toolkit.lib.common.exception.AzureExceptionHandler;
52+
import com.microsoft.azure.toolkit.lib.common.exception.AzureToolkitRuntimeException;
5153
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
5254
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperationBundle;
5355
import com.microsoft.azure.toolkit.lib.common.operation.IAzureOperationTitle;
@@ -67,10 +69,20 @@
6769
import org.apache.commons.lang.StringUtils;
6870

6971
import javax.swing.*;
70-
import java.io.*;
72+
import java.io.ByteArrayOutputStream;
73+
import java.io.File;
74+
import java.io.FileOutputStream;
75+
import java.io.IOException;
76+
import java.io.InputStream;
77+
import java.io.OutputStream;
7178
import java.nio.charset.StandardCharsets;
7279
import java.time.ZonedDateTime;
73-
import java.util.*;
80+
import java.util.ArrayList;
81+
import java.util.Arrays;
82+
import java.util.LinkedHashSet;
83+
import java.util.List;
84+
import java.util.Objects;
85+
import java.util.Set;
7486
import java.util.concurrent.ExecutionException;
7587

7688
@Log
@@ -209,11 +221,11 @@ public void setProperties(@NotNull String name, @NotNull String[] value) {
209221
@Override
210222
public List<ArtifactDescriptor> getArtifacts(@NotNull ProjectDescriptor projectDescriptor)
211223
throws AzureCmdException {
212-
Project project = findOpenProject(projectDescriptor);
224+
final Project project = findOpenProject(projectDescriptor);
213225

214-
List<ArtifactDescriptor> artifactDescriptors = new ArrayList<ArtifactDescriptor>();
226+
final List<ArtifactDescriptor> artifactDescriptors = new ArrayList<>();
215227

216-
for (Artifact artifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
228+
for (final Artifact artifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
217229
artifactDescriptors.add(new ArtifactDescriptor(artifact.getName(), artifact.getArtifactType().getId()));
218230
}
219231

@@ -225,13 +237,13 @@ public List<ArtifactDescriptor> getArtifacts(@NotNull ProjectDescriptor projectD
225237
public ListenableFuture<String> buildArtifact(@NotNull ProjectDescriptor projectDescriptor,
226238
@NotNull ArtifactDescriptor artifactDescriptor) {
227239
try {
228-
Project project = findOpenProject(projectDescriptor);
240+
final Project project = findOpenProject(projectDescriptor);
229241

230242
final Artifact artifact = findProjectArtifact(project, artifactDescriptor);
231243

232244
final SettableFuture<String> future = SettableFuture.create();
233245

234-
Futures.addCallback(buildArtifact(project, artifact, false), new FutureCallback<Boolean>() {
246+
Futures.addCallback(buildArtifact(project, artifact, false), new FutureCallback<>() {
235247
@Override
236248
public void onSuccess(@Nullable Boolean succeded) {
237249
if (succeded != null && succeded) {
@@ -254,7 +266,7 @@ public void onFailure(Throwable throwable) {
254266
}, MoreExecutors.directExecutor());
255267

256268
return future;
257-
} catch (AzureCmdException e) {
269+
} catch (final AzureCmdException e) {
258270
return Futures.immediateFailedFuture(e);
259271
}
260272
}
@@ -266,10 +278,10 @@ public Object getCurrentProject() {
266278

267279
@NotNull
268280
private static byte[] getArray(@NotNull InputStream is) throws IOException {
269-
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
281+
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
270282

271283
int readCount;
272-
byte[] data = new byte[16384];
284+
final byte[] data = new byte[16384];
273285

274286
while ((readCount = is.read(data, 0, data.length)) != -1) {
275287
buffer.write(data, 0, readCount);
@@ -283,17 +295,12 @@ private static byte[] getArray(@NotNull InputStream is) throws IOException {
283295
private static ListenableFuture<Boolean> buildArtifact(@NotNull Project project, final @NotNull Artifact artifact, boolean rebuild) {
284296
final SettableFuture<Boolean> future = SettableFuture.create();
285297

286-
Set<Artifact> artifacts = new LinkedHashSet<Artifact>(1);
298+
final Set<Artifact> artifacts = new LinkedHashSet<>(1);
287299
artifacts.add(artifact);
288-
CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, rebuild);
300+
final CompileScope scope = ArtifactCompileScope.createArtifactsScope(project, artifacts, rebuild);
289301
ArtifactsWorkspaceSettings.getInstance(project).setArtifactsToBuild(artifacts);
290302

291-
CompilerManager.getInstance(project).make(scope, new CompileStatusNotification() {
292-
@Override
293-
public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
294-
future.set(!aborted && errors == 0);
295-
}
296-
});
303+
CompilerManager.getInstance(project).make(scope, (aborted, errors, warnings, compileContext) -> future.set(!aborted && errors == 0));
297304

298305
return future;
299306
}
@@ -303,7 +310,7 @@ private static Project findOpenProject(@NotNull ProjectDescriptor projectDescrip
303310
throws AzureCmdException {
304311
Project project = null;
305312

306-
for (Project openProject : ProjectManager.getInstance().getOpenProjects()) {
313+
for (final Project openProject : ProjectManager.getInstance().getOpenProjects()) {
307314
if (StringUtils.equals(projectDescriptor.getName(), openProject.getName()) &&
308315
StringUtils.equals(projectDescriptor.getPath(), openProject.getBasePath())) {
309316
project = openProject;
@@ -323,7 +330,7 @@ private static Artifact findProjectArtifact(@NotNull Project project, @NotNull A
323330
throws AzureCmdException {
324331
Artifact artifact = null;
325332

326-
for (Artifact projectArtifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
333+
for (final Artifact projectArtifact : ArtifactUtil.getArtifactWithOutputPaths(project)) {
327334
if (artifactDescriptor.getName().equals(projectArtifact.getName()) &&
328335
artifactDescriptor.getArtifactType().equals(projectArtifact.getArtifactType().getId())) {
329336
artifact = projectArtifact;
@@ -341,7 +348,7 @@ private static Artifact findProjectArtifact(@NotNull Project project, @NotNull A
341348
public void openLinkInBrowser(@NotNull String url) {
342349
try {
343350
BrowserUtil.browse(url);
344-
} catch (Exception e) {
351+
} catch (final Exception e) {
345352
DefaultLoader.getUIHelper().showException("Unexpected exception: " + e.getMessage(), e, "Browse Web App", true, false);
346353
DefaultLoader.getUIHelper().logError("Unexpected exception: " + e.getMessage(), e);
347354
}
@@ -456,7 +463,7 @@ private boolean openFileInEditor(final Consumer<String> contentSaver, VirtualFil
456463
if (editors.length == 0) {
457464
return false;
458465
}
459-
for (FileEditor fileEditor : editors) {
466+
for (final FileEditor fileEditor : editors) {
460467
if (fileEditor instanceof TextEditor) {
461468
final String originContent = getTextEditorContent((TextEditor) fileEditor);
462469
final MessageBusConnection messageBusConnection = fileEditorManager.getProject().getMessageBus().connect(fileEditor);
@@ -466,13 +473,13 @@ public void beforeFileClosed(FileEditorManager source, VirtualFile file) {
466473
try {
467474
final String content = getTextEditorContent((TextEditor) fileEditor);
468475
if (file == virtualFile && !StringUtils.equals(content, originContent)) {
469-
boolean result = DefaultLoader.getUIHelper().showYesNoDialog(
476+
final boolean result = DefaultLoader.getUIHelper().showYesNoDialog(
470477
fileEditor.getComponent(), SAVE_CHANGES, APP_SERVICE_FILE_EDITING, Messages.getQuestionIcon());
471478
if (result) {
472479
contentSaver.consume(content);
473480
}
474481
}
475-
} catch (RuntimeException e) {
482+
} catch (final RuntimeException e) {
476483
AzureExceptionHandler.getInstance().handleException(e);
477484
} finally {
478485
messageBusConnection.disconnect();

0 commit comments

Comments
 (0)